@viswa-test/test-citation 0.0.323 → 0.0.325

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 (154) hide show
  1. package/README.md +9 -3
  2. package/dist/cjs/features/ChatCitation/InternalChatCitationRenderer.js +1 -1
  3. package/dist/cjs/features/CodeCitation/CodeCitation.js +1 -1
  4. package/dist/cjs/features/CodeCitation/_components/CodeCitationPopup.js +1 -1
  5. package/dist/cjs/features/CodeCitation/_components/RepoAndBranchTag.js +2 -0
  6. package/dist/cjs/features/CodeCitation/_components/RepoAndBranchTag.js.map +1 -0
  7. package/dist/cjs/features/CognitiveCompare/CitationAnchor.js +1 -1
  8. package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
  9. package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
  10. package/dist/cjs/features/CognitiveCompare/CognitivePopup.js +1 -1
  11. package/dist/cjs/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +1 -1
  12. package/dist/cjs/features/CognitiveCompare/Guidelines/components/WebGptPanel.js +1 -1
  13. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
  14. package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  15. package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  16. package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  17. package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  18. package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  19. package/dist/cjs/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
  20. package/dist/cjs/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js +1 -1
  21. package/dist/cjs/features/GptWebCitation/GptWebCitation.js +1 -1
  22. package/dist/cjs/features/GptWebCitation/GptWebCitationImageCitation.js +1 -1
  23. package/dist/cjs/features/GptWebCitation/utils/fixedHeight.utils.js +1 -1
  24. package/dist/cjs/features/PdfViewer/PdfContainer.js +1 -1
  25. package/dist/cjs/features/PdfViewer/PdfStyle.js +1 -1
  26. package/dist/cjs/features/PdfViewer/PdfToolbar.js +1 -1
  27. package/dist/cjs/features/PdfViewer/PdfViewer.js +1 -1
  28. package/dist/cjs/features/PromptemonBlockViewer/PromptemonBlockViewer.js +1 -1
  29. package/dist/cjs/features/PromptemonViewer/PromptemonViewer.js +1 -1
  30. package/dist/cjs/features/SPBAnalysisPanel/Cognitivereasoningpanel.js +1 -1
  31. package/dist/cjs/features/SPBAnalysisPanel/DependencyGraph.js +1 -1
  32. package/dist/cjs/features/SPBAnalysisPanel/Markdownrenderer.js +1 -1
  33. package/dist/cjs/features/SPBAnalysisPanel/Spbanalysispanel.js +1 -1
  34. package/dist/cjs/features/SegmentReviewComponents/BoundaryCard.js +1 -1
  35. package/dist/cjs/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js +1 -1
  36. package/dist/cjs/features/SegmentReviewComponents/helper.js +1 -1
  37. package/dist/cjs/hooks/useOnDemandCitationFetch.js +1 -1
  38. package/dist/cjs/index.js +1 -1
  39. package/dist/cjs/service/onDemandApi.js +1 -1
  40. package/dist/features/ChatCitation/InternalChatCitationRenderer.js +1 -1
  41. package/dist/features/CodeCitation/CodeCitation.js +1 -1
  42. package/dist/features/CodeCitation/_components/CodeCitationPopup.js +1 -1
  43. package/dist/features/CodeCitation/_components/RepoAndBranchTag.js +2 -0
  44. package/dist/features/CodeCitation/_components/RepoAndBranchTag.js.map +1 -0
  45. package/dist/features/CognitiveCompare/CitationAnchor.js +1 -1
  46. package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
  47. package/dist/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
  48. package/dist/features/CognitiveCompare/CognitivePopup.js +1 -1
  49. package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +1 -1
  50. package/dist/features/CognitiveCompare/Guidelines/components/WebGptPanel.js +1 -1
  51. package/dist/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
  52. package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  53. package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  54. package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  55. package/dist/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  56. package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  57. package/dist/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
  58. package/dist/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js +1 -1
  59. package/dist/features/GptWebCitation/GptWebCitation.js +1 -1
  60. package/dist/features/GptWebCitation/GptWebCitationImageCitation.js +1 -1
  61. package/dist/features/GptWebCitation/utils/fixedHeight.utils.js +1 -1
  62. package/dist/features/PdfViewer/PdfContainer.js +1 -1
  63. package/dist/features/PdfViewer/PdfStyle.js +1 -1
  64. package/dist/features/PdfViewer/PdfToolbar.js +1 -1
  65. package/dist/features/PdfViewer/PdfViewer.js +1 -1
  66. package/dist/features/PromptemonBlockViewer/PromptemonBlockViewer.js +1 -1
  67. package/dist/features/PromptemonViewer/PromptemonViewer.js +1 -1
  68. package/dist/features/SPBAnalysisPanel/Cognitivereasoningpanel.js +1 -1
  69. package/dist/features/SPBAnalysisPanel/DependencyGraph.js +1 -1
  70. package/dist/features/SPBAnalysisPanel/Markdownrenderer.js +1 -1
  71. package/dist/features/SPBAnalysisPanel/Spbanalysispanel.js +1 -1
  72. package/dist/features/SegmentReviewComponents/BoundaryCard.js +1 -1
  73. package/dist/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js +1 -1
  74. package/dist/features/SegmentReviewComponents/helper.js +1 -1
  75. package/dist/hooks/useOnDemandCitationFetch.js +1 -1
  76. package/dist/index.js +1 -1
  77. package/dist/service/onDemandApi.js +1 -1
  78. package/dist/types/src/CodeCitationTest.d.ts.map +1 -1
  79. package/dist/types/src/PdfViewerTest.d.ts.map +1 -1
  80. package/dist/types/src/Spbanalysispaneltest.d.ts.map +1 -1
  81. package/dist/types/src/features/ChatCitation/InternalChatCitationRenderer.d.ts.map +1 -1
  82. package/dist/types/src/features/CodeCitation/CodeCitation.d.ts +2 -0
  83. package/dist/types/src/features/CodeCitation/CodeCitation.d.ts.map +1 -1
  84. package/dist/types/src/features/CodeCitation/_components/CodeCitationPopup.d.ts +3 -0
  85. package/dist/types/src/features/CodeCitation/_components/CodeCitationPopup.d.ts.map +1 -1
  86. package/dist/types/src/features/CodeCitation/_components/RepoAndBranchTag.d.ts +8 -0
  87. package/dist/types/src/features/CodeCitation/_components/RepoAndBranchTag.d.ts.map +1 -0
  88. package/dist/types/src/features/CognitiveCompare/CitationAnchor.d.ts.map +1 -1
  89. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts +1 -1
  90. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
  91. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +1 -1
  92. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
  93. package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts +0 -12
  94. package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts.map +1 -1
  95. package/dist/types/src/features/CognitiveCompare/Guidelines/components/GuidelinePanel.d.ts.map +1 -1
  96. package/dist/types/src/features/CognitiveCompare/Guidelines/components/WebGptPanel.d.ts.map +1 -1
  97. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts +1 -14
  98. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts.map +1 -1
  99. package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
  100. package/dist/types/src/features/CognitiveCompare/components/SubSectionAccordion.d.ts.map +1 -1
  101. package/dist/types/src/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts.map +1 -1
  102. package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts +1 -1
  103. package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
  104. package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts +1 -0
  105. package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts.map +1 -1
  106. package/dist/types/src/features/CognitiveCompare/hooks/useLinesCalculator.d.ts.map +1 -1
  107. package/dist/types/src/features/CognitiveCompare/hooks/useSideBySide.d.ts.map +1 -1
  108. package/dist/types/src/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.d.ts +0 -1
  109. package/dist/types/src/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.d.ts.map +1 -1
  110. package/dist/types/src/features/GptWebCitation/GptWebCitation.d.ts.map +1 -1
  111. package/dist/types/src/features/GptWebCitation/GptWebCitationImageCitation.d.ts +1 -2
  112. package/dist/types/src/features/GptWebCitation/GptWebCitationImageCitation.d.ts.map +1 -1
  113. package/dist/types/src/features/GptWebCitation/types.d.ts +0 -11
  114. package/dist/types/src/features/GptWebCitation/types.d.ts.map +1 -1
  115. package/dist/types/src/features/GptWebCitation/utils/fixedHeight.utils.d.ts +0 -2
  116. package/dist/types/src/features/GptWebCitation/utils/fixedHeight.utils.d.ts.map +1 -1
  117. package/dist/types/src/features/PdfViewer/PdfContainer.d.ts +5 -3
  118. package/dist/types/src/features/PdfViewer/PdfContainer.d.ts.map +1 -1
  119. package/dist/types/src/features/PdfViewer/PdfStyle.d.ts.map +1 -1
  120. package/dist/types/src/features/PdfViewer/PdfToolbar.d.ts +7 -2
  121. package/dist/types/src/features/PdfViewer/PdfToolbar.d.ts.map +1 -1
  122. package/dist/types/src/features/PdfViewer/PdfViewer.d.ts +26 -2
  123. package/dist/types/src/features/PdfViewer/PdfViewer.d.ts.map +1 -1
  124. package/dist/types/src/features/PromptemonBlockViewer/PromptemonBlockViewer.d.ts +15 -2
  125. package/dist/types/src/features/PromptemonBlockViewer/PromptemonBlockViewer.d.ts.map +1 -1
  126. package/dist/types/src/features/SPBAnalysisPanel/Cognitivereasoningpanel.d.ts +31 -1
  127. package/dist/types/src/features/SPBAnalysisPanel/Cognitivereasoningpanel.d.ts.map +1 -1
  128. package/dist/types/src/features/SPBAnalysisPanel/DependencyGraph.d.ts +36 -2
  129. package/dist/types/src/features/SPBAnalysisPanel/DependencyGraph.d.ts.map +1 -1
  130. package/dist/types/src/features/SPBAnalysisPanel/Markdownrenderer.d.ts +7 -1
  131. package/dist/types/src/features/SPBAnalysisPanel/Markdownrenderer.d.ts.map +1 -1
  132. package/dist/types/src/features/SPBAnalysisPanel/Spbanalysispanel.d.ts +86 -1
  133. package/dist/types/src/features/SPBAnalysisPanel/Spbanalysispanel.d.ts.map +1 -1
  134. package/dist/types/src/features/SPBAnalysisPanel/index.d.ts +1 -1
  135. package/dist/types/src/features/SPBAnalysisPanel/index.d.ts.map +1 -1
  136. package/dist/types/src/features/SegmentReviewComponents/BoundaryCard.d.ts +4 -2
  137. package/dist/types/src/features/SegmentReviewComponents/BoundaryCard.d.ts.map +1 -1
  138. package/dist/types/src/features/SegmentReviewComponents/SegmentReviewPdfWrapper.d.ts.map +1 -1
  139. package/dist/types/src/features/SegmentReviewComponents/helper.d.ts +5 -5
  140. package/dist/types/src/features/SegmentReviewComponents/helper.d.ts.map +1 -1
  141. package/dist/types/src/features/SegmentReviewComponents/helper.test.d.ts +2 -0
  142. package/dist/types/src/features/SegmentReviewComponents/helper.test.d.ts.map +1 -0
  143. package/dist/types/src/features/SegmentReviewComponents/index.d.ts +4 -7
  144. package/dist/types/src/features/SegmentReviewComponents/index.d.ts.map +1 -1
  145. package/dist/types/src/features/SegmentReviewComponents/reviewStepAdapters.d.ts +1 -0
  146. package/dist/types/src/features/SegmentReviewComponents/reviewStepAdapters.d.ts.map +1 -1
  147. package/dist/types/src/hooks/useOnDemandCitationFetch.d.ts.map +1 -1
  148. package/dist/types/src/index.d.ts +6 -0
  149. package/dist/types/src/index.d.ts.map +1 -1
  150. package/dist/types/src/service/onDemandApi.d.ts +2 -2
  151. package/dist/types/src/service/onDemandApi.d.ts.map +1 -1
  152. package/dist/types/src/types/onDemandApi.types.d.ts +5 -0
  153. package/dist/types/src/types/onDemandApi.types.d.ts.map +1 -1
  154. package/package.json +9 -4
@@ -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 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};
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};
2
2
  //# sourceMappingURL=GptWebCitation.js.map
@@ -1,2 +1,2 @@
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};
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};
2
2
  //# sourceMappingURL=GptWebCitationImageCitation.js.map
@@ -1,2 +1,2 @@
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};
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};
2
2
  //# sourceMappingURL=fixedHeight.utils.js.map
@@ -1,2 +1,2 @@
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};
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};
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",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};
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};
2
2
  //# sourceMappingURL=PdfStyle.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e}from"tslib";import{jsxs as n,jsx as t}from"react/jsx-runtime";import{pdfStyles as i}from"./PdfStyle.js";import{DefaultPdfIcon as o,DefaultFullScreenIcon as l,DefaultDownloadIcon as r,DefaultCloseIcon as d}from"../../assests/svg/PdfViewerIcons.js";import{Tooltip as s}from"@mui/material";var c=function(c){c.highlightIndex;var a=c.totalHighlights,p=c.controls,h=c.currentPosition,u=c.pdfName,f=c.onClose,x=c.pdfUrl,g=c.viewerRef,m=c.customStyles,v=c.customClasses,y=c.customIcons,w=c.headerAction,b=c.isZoomEnabled,k=void 0===b||b,I=c.showHighlightsAction,C=void 0===I||I,S=c.showFullScreenAction,F=void 0===S||S,D=p.ZoomInButton,j=p.ZoomOutButton,L=p.ZoomPopover,W=p.goToPrevious,B=p.goToNext,A={padding:"4px",borderRadius:"6px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease",flexShrink:0};return n("div",e({style:e(e({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px",background:"#FAFAFA",borderBottom:"1px solid #F3F4F6",borderTopLeftRadius:"12px",borderTopRightRadius:"12px"},i.header),null==m?void 0:m.header)},{children:[n("div",e({style:{display:"flex",alignItems:"center",gap:"12px",flex:1,minWidth:0,overflow:"hidden"}},{children:[t("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==m?void 0:m.pdfIconWrapper),{flexShrink:0})},{children:(null==y?void 0:y.pdfIcon)||t(o,{})})),t(s,e({title:u||"",arrow:!0,placement:"top"},{children:t("div",e({style:{flex:1,minWidth:0,overflow:"hidden"}},{children:t("span",e({style:e({display:"block",width:"100%",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontWeight:500,cursor:"default"},null==m?void 0:m.pdfName),className:null==v?void 0:v.pdfName},{children:u}))}))}))]})),n("div",e({style:{display:"flex",alignItems:"center",gap:C?"16px":"2px",color:"#4B5563",flexShrink:0,whiteSpace:"nowrap",minWidth:"fit-content"}},{children:[k&&n("div",e({style:{display:"flex",alignItems:"center",gap:"4px"}},{children:[t(j,{}),t("div",e({style:{fontSize:"14px",fontWeight:500,width:"56px",textAlign:"center"}},{children:t(L,{})})),t(D,{})]})),!!a&&C&&n("div",e({style:{display:"flex",alignItems:"center",gap:"4px"}},{children:[n("span",e({style:{fontSize:"14px",color:"#475467",fontWeight:500,lineHeight:1}},{children:[h," of ",a]})),t("button",e({style:{background:"none",border:"none",cursor:h<=1?"not-allowed":"pointer",padding:"2px 4px",color:h<=1?"#D0D5DD":"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px"},onClick:W,disabled:h<=1},{children:t("svg",e({width:"12",height:"12",viewBox:"0 0 12 12",fill:"none"},{children:t("path",{d:"M2 8L6 4L10 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}))})),t("button",e({style:{background:"none",border:"none",cursor:h===a?"not-allowed":"pointer",padding:"2px 4px",color:h===a?"#D0D5DD":"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px"},onClick:B,disabled:h===a},{children:t("svg",e({width:"12",height:"12",viewBox:"0 0 12 12",fill:"none"},{children:t("path",{d:"M2 4L6 8L10 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}))}))]})),t("div",{style:{width:"1px",height:"20px",background:"#D1D5DB",margin:"0 4px",flexShrink:0}}),n("div",e({style:{display:"flex",alignItems:"center",gap:"8px",flexShrink:0,whiteSpace:"nowrap"}},{children:[!1!==F&&((null==w?void 0:w.icon)&&(null==w?void 0:w.onClick)?t(s,e({title:(null==w?void 0:w.tooltip)||"",arrow:!0,placement:"top"},{children:t("div",e({onClick:w.onClick,style:e({display:"flex",alignItems:"center",cursor:"pointer"},A)},{children:w.icon}))})):t("button",e({onClick:function(){var e=null==g?void 0:g.current;e&&(document.fullscreenElement?document.exitFullscreen():e.requestFullscreen().catch(function(e){console.error("Error attempting to enable fullscreen: ".concat(e.message))}))},style:A,title:"Full Screen"},{children:(null==y?void 0:y.fullScreenIcon)||t(l,{})}))),x&&t("a",e({href:x,target:"_blank",rel:"noopener noreferrer",style:A,title:"Open in new tab"},{children:(null==y?void 0:y.downloadIcon)||t(r,{})})),f&&t("button",e({onClick:f,style:A,title:"Close"},{children:(null==y?void 0:y.closeIcon)||t(d,{})}))]}))]}))]}))};export{c 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 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};
2
2
  //# sourceMappingURL=PdfToolbar.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e,__awaiter as t,__generator as i}from"tslib";import{jsx as o,jsxs as n}from"react/jsx-runtime";import{SpecialZoomLevel as r}from"@react-pdf-viewer/core";import a from"./PdfContainer.js";import l from"./PdfToolbar.js";import{pdfStyles as s}from"./PdfStyle.js";import{PdfHighlightControls as c}from"./usePdfHighlight.js";import"@react-pdf-viewer/zoom/lib/styles/index.css";import"@react-pdf-viewer/page-navigation/lib/styles/index.css";import"@react-pdf-viewer/core/lib/styles/index.css";import"@react-pdf-viewer/search/lib/styles/index.css";import{useRef as u,useMemo as d,useEffect as g}from"react";import f from"../ScannedDocCitation/ScannedDocCitation.js";var h=function(e){switch(e){case"ActualSize":return r.ActualSize;case"PageFit":return r.PageFit;case"PageWidth":return r.PageWidth;default:return null!=e?e:r.PageWidth}},m=function(m){var v,p=m.pdfUrl,x=m.highlightText,C=m.highlightPages,P=m.highlightCordinatePages,w=m.highlightColor,T=void 0===w?"yellow":w,S=m.activeHighlightColor,y=void 0===S?"#f7dc51":S,A=m.jumpToPageValue,b=void 0===A?0:A,H=m.pdfName,I=m.onClose,j=m.customStyles,F=m.customClasses,z=m.customIcons,N=m.useCoordinates,_=m.fallbackPages,R=m.activeCitationIndex,V=m.onActiveCitationChange,W=m.headerAction,q=m.isZoomEnabled,D=void 0===q||q,E=m.showHighlightsAction,B=void 0===E||E,O=m.defaultScale,U=void 0===O?r.ActualSize:O,k=m.useRange,Z=void 0!==k&&k,J=m.rangeOfPages,K=void 0===J?null:J,L=m.showFullScreenAction,G=void 0===L||L,M=u(null),Q=d(function(){if(N)return new Set(P.map(function(e){return e.pageIndex}));var e=new Set;return Object.values(C).forEach(function(t){t>0&&e.add(t-1)}),e},[P,C,N]),X=(v=x)&&0!==v.length?v.filter(function(e){return!v.some(function(t){return t!==e&&t.includes(e)})}):v,Y=c(X,N?{}:C,M,Q,N,N?P:[],T,y),$=Y.highlightIndex,ee=Y.cursorIndex,te=Y.setCursorIndex,ie=Y.orderedKeys,oe=Y.totalHighlights,ne=Y.getValidPosition,re=Y.tryJump,ae=Y.jumpToPage,le=Y.zoomTo,se=Y.plugins,ce=Y.controls,ue=Y.hideNonTargetHighlights,de=Y.deduplicateHighlights,ge=ne(ee);g(function(){void 0!==R&&R!==ee&&te(R)},[R]);var fe=e(e({},ce),{goToNext:function(){ee>=oe-1||(ce.goToNext(),V&&V(ee+1))},goToPrevious:function(){ee<=0||(ce.goToPrevious(),V&&V(ee-1))}});if(!p)return o(f,{pages:_,activeCitationIndex:R,onActiveCitationChange:V,headerAction:W});return n("div",e({ref:M,className:(null==F?void 0:F.pdfViewerWrapper)||"",style:e(e(e({height:"100%",minHeight:0,minWidth:0,overflow:"hidden",display:"flex",flexDirection:"column"},s.pdfViewer),{display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"#FAFAFA"}),null==j?void 0:j.pdfViewer)},{children:[o(l,{highlightIndex:$,totalHighlights:oe,controls:fe,currentPosition:ge,pdfName:H,onClose:I,pdfUrl:p,viewerRef:M,customStyles:j,customClasses:F,customIcons:z,headerAction:W,isZoomEnabled:D,showHighlightsAction:B,showFullScreenAction:G}),o(a,{defaultScale:h(U),pdfUrl:p,plugins:se,customStyles:j,onLoad:function(){var e=!N&&!Z&&b<=0;if(le(r.ActualSize),b>0&&!Z){var o=b-1,n=ie[o],a=C[n],l=P[o];te(o),console.log(l,"cordinateTargetHighlight"),N&&l.pageIndex>0&&ae(l.pageIndex),a>0&&(setTimeout(function(){ue(Q),de(a-1)},1e3),N||ae(a-1))}else if(Z&&K&&2===K.length){t(void 0,void 0,void 0,function(){var e,t,o,n,r;return i(this,function(i){switch(i.label){case 0:e=K[0],t=K[1],o=e,i.label=1;case 1:return o<=t?(ae(n=o-1),[4,new Promise(function(e){return setTimeout(e,1e3)})]):[3,4];case 2:if(i.sent(),ue(Q),(r=de(n))&&r>0)return[3,4];i.label=3;case 3:return o++,[3,1];case 4:return[2]}})})}else if(!N&&C){var s=ie.find(function(e){return C[e]>0});if(void 0!==s){var c=C[s]-1;ae(c),setTimeout(function(){ue(Q),de(c)},1e3)}}requestAnimationFrame(function(){e&&re(),!N&&b>0&&!Z&&function(){if(M.current){var e=b-1,t=ie[e],i=C[t],o=i>0?i-1:0,n={};ie.forEach(function(e,t){var i=C[e];i>0&&(n[i]||(n[i]=[]),n[i].push(t))});var r=(n[i]||[]).indexOf(e),a=0,l=function(){var e,t;if(!(++a>40)){var i=null===(e=M.current)||void 0===e?void 0:e.querySelector(".rpv-core__inner-pages");if(i){var n=null===(t=M.current)||void 0===t?void 0:t.querySelector('[data-testid="core__page-layer-'.concat(o,'"]'));if(n){var s=i.getBoundingClientRect(),c=n.getBoundingClientRect();if(c.top<s.bottom&&c.bottom>s.top){var u=n.querySelectorAll(".rpv-search__highlight")[r];if(u){var d=u.getBoundingClientRect(),g=i.scrollTop+(d.top-s.top)-i.clientHeight/2+d.height/2;i.scrollTo({top:g,behavior:"smooth"})}else setTimeout(l,100)}else setTimeout(l,100)}else setTimeout(l,100)}else setTimeout(l,100)}};setTimeout(l,500)}}()})},onPageChange:function(e){var t=e.currentPage;Q.has(t)?(de(t),ue(Q)):ue(Q)}})]}))};export{m as default};
1
+ import{__assign as e,__awaiter as t,__generator as n}from"tslib";import{jsx as i,jsxs as o,Fragment as r}from"react/jsx-runtime";import{SpecialZoomLevel as a}from"@react-pdf-viewer/core";import l from"./PdfContainer.js";import c from"./PdfToolbar.js";import{pdfStyles as u}from"./PdfStyle.js";import{PdfHighlightControls as s}from"./usePdfHighlight.js";import"@react-pdf-viewer/zoom/lib/styles/index.css";import"@react-pdf-viewer/page-navigation/lib/styles/index.css";import"@react-pdf-viewer/core/lib/styles/index.css";import"@react-pdf-viewer/search/lib/styles/index.css";import d,{useRef as g,useState as f,useMemo as h,useEffect as v}from"react";import m from"../ScannedDocCitation/ScannedDocCitation.js";var p=function(e){switch(e){case"ActualSize":return a.ActualSize;case"PageFit":return a.PageFit;case"PageWidth":return a.PageWidth;default:return null!=e?e:a.PageWidth}},y=function(y){var x,P=y.pdfUrl,T=y.highlightText,w=y.highlightPages,C=y.highlightCordinatePages,b=y.highlightColor,S=void 0===b?"yellow":b,A=y.activeHighlightColor,_=void 0===A?"#f7dc51":A,I=y.jumpToPageValue,R=void 0===I?0:I,H=y.pdfName,L=y.onClose,q=y.customStyles,N=y.customClasses,j=y.customIcons,F=y.useCoordinates,B=y.fallbackPages,D=y.activeCitationIndex,M=y.onActiveCitationChange,V=y.headerAction,W=y.isZoomEnabled,z=void 0===W||W,E=y.showHighlightsAction,k=void 0===E||E,O=y.defaultScale,U=void 0===O?a.ActualSize:O,Z=y.useRange,J=void 0!==Z&&Z,K=y.rangeOfPages,G=void 0===K?null:K,Q=y.showFullScreenAction,X=void 0===Q||Q,Y=y.segments,$=void 0===Y?[{title:"Document 2",start_page:52,end_page:52,page_count:1}]:Y,ee=y.segmentTooltipText,te=y.onCurrentPageChange,ne=y.navigationRequest,ie=y.onNavigationSettled,oe=y.disablePdfAnnotations,re=void 0!==oe&&oe,ae=y.disablePdfTextLayer,le=void 0!==ae&&ae,ce=y.renderPage,ue=y.setRenderRange,se=g(null),de=f(0),ge=de[0],fe=de[1],he=f(0),ve=he[0],me=he[1],pe=g(null),ye=g(null),xe=g(0),Pe=h(function(){return re||le?function(t){var n=le?i("div",e({"aria-hidden":"true",style:{display:"none"}},{children:t.textLayer.children})):t.textLayer.children,a=e(e({},t),{annotationLayer:e(e({},t.annotationLayer),{children:re?null:t.annotationLayer.children}),textLayer:e(e({},t.textLayer),{children:n})});return ce?ce(a):o(r,{children:[t.canvasLayer.children,n,!re&&t.annotationLayer.children]})}:ce},[re,le,ce]),Te=h(function(){if(F)return new Set(C.map(function(e){return e.pageIndex}));var e=new Set;return Object.values(w).forEach(function(t){t>0&&e.add(t-1)}),e},[C,w,F]),we=(x=T)&&0!==x.length?x.filter(function(e){return!x.some(function(t){return t!==e&&t.includes(e)})}):x,Ce=s(we,F?{}:w,se,Te,F,F?C:[],S,_),be=Ce.highlightIndex,Se=Ce.cursorIndex,Ae=Ce.setCursorIndex,_e=Ce.orderedKeys,Ie=Ce.totalHighlights,Re=Ce.getValidPosition,He=Ce.tryJump,Le=Ce.jumpToPage,qe=Ce.plugins,Ne=Ce.controls,je=Ce.hideNonTargetHighlights,Fe=Ce.deduplicateHighlights,Be=Re(Se),De=h(function(){var e=ge+1;return $.find(function(t){return e>=t.start_page&&e<=t.end_page})},[ge,$]);v(function(){void 0!==D&&D!==Se&&Ae(D)},[D]);var Me=e(e({},Ne),{goToNext:function(){Se>=Ie-1||(Ne.goToNext(),M&&M(Se+1))},goToPrevious:function(){Se<=0||(Ne.goToPrevious(),M&&M(Se-1))}}),Ve=d.useCallback(function(e,t){xe.current+=1;var n=xe.current;null!=ye.current&&window.clearTimeout(ye.current);var i=null,o=0,r=0,a=function(){var l,c;if(xe.current===n){var u=null===(l=se.current)||void 0===l?void 0:l.querySelector(".rpv-core__inner-pages");if(u){var s=null===(c=se.current)||void 0===c?void 0:c.querySelector('[data-testid="core__page-layer-'.concat(t-1,'"]'));if(s){r+=1,u&&(i===u.scrollTop?o+=1:(i=u.scrollTop,o=0));var d=null==u?void 0:u.getBoundingClientRect(),g=null==s?void 0:s.getBoundingClientRect(),f=Boolean(d&&g&&g.bottom>d.top&&g.top<d.bottom);if(o>=2&&f||r>=40)return ye.current=null,void(null==ie||ie({pageNumber:t,requestId:e.requestId}));ye.current=window.setTimeout(a,50)}}}};ye.current=window.setTimeout(a,50)},[ie]);if(v(function(){return function(){xe.current+=1,null!=ye.current&&window.clearTimeout(ye.current)}},[]),v(function(){var e;if(ne&&!(ve<=0)){var t=Math.min(Math.max(Math.trunc(ne.pageNumber),1),ve),n="".concat(null!==(e=ne.requestId)&&void 0!==e?e:t,":").concat(t);pe.current!==n&&(pe.current=n,fe(t-1),Le(t-1),Ve(ne,t))}},[Le,ne,ve,Ve]),!P)return i(m,{pages:B,activeCitationIndex:D,onActiveCitationChange:M,headerAction:V});return o("div",e({ref:se,className:(null==N?void 0:N.pdfViewerWrapper)||"","data-disable-pdf-annotations":re?"true":void 0,style:e(e(e({height:"100%",minHeight:0,minWidth:0,overflow:"hidden",display:"flex",flexDirection:"column"},u.pdfViewer),{display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"#FAFAFA"}),null==q?void 0:q.pdfViewer)},{children:[i(c,{highlightIndex:be,totalHighlights:Ie,controls:Me,currentPosition:Be,pdfName:H,onClose:L,pdfUrl:P,viewerRef:se,customStyles:q,customClasses:N,customIcons:j,headerAction:V,isZoomEnabled:z,showHighlightsAction:k,showFullScreenAction:X,currentSegment:De,segmentTooltipText:ee,currentPage:ge+1,totalPages:ve,onPageNavigate:function(e){var t=Math.min(Math.max(e,1),ve||e);fe(t-1),Le(t-1)}}),i(l,{defaultScale:p(U),pdfUrl:P,plugins:qe,customStyles:q,onLoad:function(e){me(e.doc.numPages);var i=!F&&!J&&R<=0;if(R>0&&!J){var o=R-1,r=_e[o],a=w[r],l=C[o];Ae(o),console.log(l,"cordinateTargetHighlight"),F&&l.pageIndex>0&&Le(l.pageIndex),a>0&&(setTimeout(function(){je(Te),Fe(a-1)},1e3),F||Le(a-1))}else if(J&&G&&2===G.length){t(void 0,void 0,void 0,function(){var e,t,i,o,r;return n(this,function(n){switch(n.label){case 0:e=G[0],t=G[1],i=e,n.label=1;case 1:return i<=t?(Le(o=i-1),[4,new Promise(function(e){return setTimeout(e,1e3)})]):[3,4];case 2:if(n.sent(),je(Te),(r=Fe(o))&&r>0)return[3,4];n.label=3;case 3:return i++,[3,1];case 4:return[2]}})})}else if(!F&&w){var c=_e.find(function(e){return w[e]>0});if(void 0!==c){var u=w[c]-1;Le(u),setTimeout(function(){je(Te),Fe(u)},1e3)}}requestAnimationFrame(function(){i&&He(),!F&&R>0&&!J&&function(){if(se.current){var e=R-1,t=_e[e],n=w[t],i=n>0?n-1:0,o={};_e.forEach(function(e,t){var n=w[e];n>0&&(o[n]||(o[n]=[]),o[n].push(t))});var r=(o[n]||[]).indexOf(e),a=0,l=function(){var e,t;if(!(++a>40)){var n=null===(e=se.current)||void 0===e?void 0:e.querySelector(".rpv-core__inner-pages");if(n){var o=null===(t=se.current)||void 0===t?void 0:t.querySelector('[data-testid="core__page-layer-'.concat(i,'"]'));if(o){var c=n.getBoundingClientRect(),u=o.getBoundingClientRect();if(u.top<c.bottom&&u.bottom>c.top){var s=o.querySelectorAll(".rpv-search__highlight")[r];if(s){var d=s.getBoundingClientRect(),g=n.scrollTop+(d.top-c.top)-n.clientHeight/2+d.height/2;n.scrollTo({top:g,behavior:"smooth"})}else setTimeout(l,100)}else setTimeout(l,100)}else setTimeout(l,100)}else setTimeout(l,100)}};setTimeout(l,500)}}()})},onPageChange:function(e){var t=e.currentPage;fe(t),null==te||te(t+1),Te.has(t)?(Fe(t),je(Te)):je(Te)},renderPage:Pe,setRenderRange:ue})]}))};export{y as default};
2
2
  //# sourceMappingURL=PdfViewer.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e}from"tslib";import{jsxs as r,Fragment as o,jsx as t}from"react/jsx-runtime";import{useState as i,useRef as n,useEffect as l}from"react";import{Box as a,Typography as d,Tooltip as s,Dialog as c,IconButton as f,Chip as h}from"@mui/material";import g from"@mui/icons-material/Close";import m from"@mui/icons-material/Fullscreen";import u from"@monaco-editor/react";import*as p from"monaco-editor";import b from"@mui/icons-material/DarkMode";import x from"@mui/icons-material/LightMode";var v={base:"vs-dark",inherit:!0,rules:[{token:"tag",foreground:"714be3",fontStyle:"bold"},{token:"attribute.name",foreground:"87CEFA"},{token:"attribute.value",foreground:"98FB98"},{token:"variable",foreground:"00FFFF"},{token:"delimiter",foreground:"888888"},{token:"white",foreground:"AAAAAA"}],colors:{"editor.foreground":"#FFFFFF","editor.background":"#030202","editorLineNumber.foreground":"#858585","editorCursor.foreground":"#FFFFFF","editorIndentGuide.background":"#404040","editorIndentGuide.activeBackground":"#707070"}},k={base:"vs",inherit:!0,rules:[{token:"tag",foreground:"5928ED",fontStyle:"bold"},{token:"attribute.name",foreground:"AF00DB"},{token:"attribute.value",foreground:"008000"},{token:"variable",foreground:"B000B0"},{token:"delimiter",foreground:"808080"},{token:"white",foreground:"000000"}],colors:{"editor.foreground":"#000000","editor.background":"#FFFFFF","editorLineNumber.foreground":"#999999","editorCursor.foreground":"#000000","editorIndentGuide.background":"#CCCCCC","editorIndentGuide.activeBackground":"#999999"}},w=function(r){var o=r.isDarkMode,i=r.onChange;return t(a,e({onClick:function(){return i(!o)},sx:{width:52,height:24,borderRadius:"12px",bgcolor:o?"#5928ed":"#f0f0f0",border:"1px solid",borderColor:o?"#5928ed":"#d1d5db",display:"flex",alignItems:"center",px:.4,cursor:"pointer",transition:"all 0.2s",justifyContent:o?"flex-end":"flex-start"}},{children:t(a,e({sx:{width:18,height:18,borderRadius:"50%",bgcolor:o?"#1e1e2e":"#f59e0b",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s"}},{children:t(o?b:x,{sx:{fontSize:11,color:"#fff"}})}))}))},C=function(i){var d=i.content,s=i.selectedTag,c=i.highlightVariable,f=i.isDarkMode,h=i.height,g=void 0===h?250:h,m=i.fontSize,b=void 0===m?12:m,x=n(),w=n();return l(function(){if(s&&x.current&&w.current){var e=x.current,r=e.getModel();if(r){for(var o=r.getValue().split("\n"),t=-1,i=0;i<o.length;i++){var n=o[i].match(/<([^\s>\/]+(?:\s[^\s>\/]+)*)/);if(n&&n[1].trim().toLowerCase()===s.toLowerCase()){t=i+1;break}}if(t>0){var l=t,a="</".concat(s.toLowerCase(),">");for(i=t;i<o.length;i++)if(o[i].toLowerCase().includes(a)){l=i+1;break}e.setSelection(new w.current.Selection(t,1,t,1)),e.trigger(null,"editor.unfold",{}),e.revealLineInCenterIfOutsideViewport(t);var d=e.deltaDecorations([],[{range:new w.current.Range(t,1,l,o[l-1].length+1),options:{isWholeLine:!0,className:"promptemon-highlight",inlineClassName:"promptemon-highlight"}}]);setTimeout(function(){return e.deltaDecorations(d,[])},2e3)}}}},[s]),l(function(){if(c&&x.current&&w.current){var e=x.current,r=e.getModel();if(r){for(var o=r.getValue().split("\n"),t=[],i=0;i<o.length;i++)for(var n=o[i].indexOf(c);-1!==n;)t.push(new p.Range(i+1,n+1,i+1,n+c.length+1)),n=o[i].indexOf(c,n+1);if(0!==t.length){e.revealLineInCenterIfOutsideViewport(t[0].startLineNumber);var l=e.deltaDecorations([],t.map(function(e){return{range:e,options:{inlineClassName:"promptemon-variable-highlight"}}}));setTimeout(function(){return e.deltaDecorations(l,[])},2e3)}}}},[c]),l(function(){w.current&&w.current.editor.setTheme(f?"promptemonDark":"promptemonLight")},[f]),r(o,{children:[t("style",{children:"\n .promptemon-highlight { background-color: rgba(89, 40, 237, 0.15); }\n .promptemon-variable-highlight { background-color: rgba(0, 255, 255, 0.2); border-radius: 2px; }\n "}),r(a,e({sx:{width:"100%",height:g,display:"flex",flexDirection:"column"}},{children:[t(a,{sx:{width:"100%",height:20,bgcolor:f?"#030202":"#fff",borderTopLeftRadius:8,borderTopRightRadius:8}}),t(a,e({sx:{flex:1,minHeight:0,overflow:"hidden"}},{children:t(u,{onMount:function(e,r){x.current=e,w.current=r,r.editor.defineTheme("promptemonDark",v),r.editor.defineTheme("promptemonLight",k),r.editor.setTheme(f?"promptemonDark":"promptemonLight"),r.languages.register({id:"promptemonLang"}),r.languages.setMonarchTokensProvider("promptemonLang",{tokenizer:{root:[[/(<)([a-zA-Z0-9\-]+)(\s*)/,["delimiter","tag","white"],"@tagBody"],[/(<\/)([a-zA-Z0-9\-]+)(\s*)(>)/,["delimiter","tag","white","delimiter"]],[/{{[^}]+}}/,"variable"]],tagBody:[[/[a-zA-Z0-9\:\-]+(?=\=)/,"attribute.name"],[/=/,"delimiter"],[/(".*?"|'.*?')/,"attribute.value"],[/\s+/,"white"],[/(\/?>)/,{token:"delimiter",next:"@pop"}]]}}),r.languages.registerFoldingRangeProvider("promptemonLang",{provideFoldingRanges:function(e){var r=e.getLinesContent(),o=[],t=[];return r.forEach(function(e,r){var i=r+1,n=e.match(/<([a-zA-Z0-9\-]+)(\s[^>]*)?>/),l=e.match(/<\/([a-zA-Z0-9\-]+)>/);if(n&&!e.includes("/>")&&t.push({tag:n[1],start:i}),l)for(var a=l[1],d=t.length-1;d>=0;d--)if(t[d].tag===a){o.push({start:t[d].start,end:i}),t.splice(d,1);break}}),o}})},beforeMount:function(e){e.editor.defineTheme("promptemonDark",v),e.editor.defineTheme("promptemonLight",k),e.editor.setTheme(f?"promptemonDark":"promptemonLight")},theme:f?"promptemonDark":"promptemonLight",value:d,language:"promptemonLang",onChange:function(){},options:{fontSize:b,minimap:{enabled:!1},wordWrap:"on",lineNumbers:"on",readOnly:!0,domReadOnly:!0,scrollBeyondLastLine:!1,padding:{top:4,bottom:12},folding:!0,automaticLayout:!0,scrollbar:{vertical:"visible",horizontal:"visible",verticalScrollbarSize:8}}})})),t(a,{sx:{width:"100%",height:20,bgcolor:f?"#030202":"#fff",borderBottomLeftRadius:8,borderBottomRightRadius:8}})]}))]})},y=function(n){var l=n.title,u=n.description,p=n.content,b=n.height,x=void 0===b?250:b,v=n.selectedTag,k=n.highlightVariable,y=i(!0),F=y[0],L=y[1],z=i(!1),D=z[0],B=z[1];return r(o,{children:[r(a,e({sx:{border:"1px solid #e5e7eb",borderRadius:"8px",overflow:"hidden"}},{children:[r(a,e({sx:{px:1.5,py:.75,bgcolor:"#f9fafb",borderBottom:"1px solid #e5e7eb",display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[t(d,e({sx:{fontSize:"0.72rem",color:"#374151",fontWeight:600}},{children:l})),r(a,e({sx:{display:"flex",alignItems:"center",gap:.75}},{children:[t(w,{isDarkMode:F,onChange:L}),t(s,e({title:"Fullscreen",placement:"top"},{children:t(a,e({onClick:function(){return B(!0)},sx:{cursor:"pointer",display:"flex",alignItems:"center",p:.3,borderRadius:"4px","&:hover":{bgcolor:"#e5e7eb"}}},{children:t(m,{sx:{fontSize:"0.9rem",color:"#6b7280"}})}))}))]}))]})),t(a,e({sx:{height:x,bgcolor:F?"#030202":"#fff"}},{children:t(C,{content:p,selectedTag:v,highlightVariable:k,isDarkMode:F,height:x,fontSize:12})}))]})),r(c,e({open:D,onClose:function(){return B(!1)},maxWidth:!1,PaperProps:{sx:{width:"82vw",height:"80vh",maxWidth:"none",borderRadius:"12px",overflow:"hidden",display:"flex",flexDirection:"column"}}},{children:[r(a,e({sx:{px:2.5,py:1.5,borderBottom:"1px solid #E5E7EB",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0}},{children:[t(d,e({sx:{fontWeight:700,fontSize:"1rem",color:"#111827"}},{children:l})),t(f,e({size:"small",onClick:function(){return B(!1)}},{children:t(g,{sx:{fontSize:"1.1rem",color:"#6B7280"}})}))]})),r(a,e({sx:{flex:1,display:"flex",overflow:"hidden",minHeight:0}},{children:[u&&r(a,e({sx:{width:"35%",flexShrink:0,borderRight:"1px solid #E5E7EB",display:"flex",flexDirection:"column",overflow:"hidden"}},{children:[r(a,e({sx:{px:2,py:1.25,borderBottom:"1px solid #E5E7EB",display:"flex",alignItems:"center",gap:1}},{children:[t(h,{label:"APB",size:"small",sx:{bgcolor:"#f1f5f9",color:"#475569",fontWeight:700,fontSize:10,height:20,borderRadius:1}}),t(d,e({sx:{fontWeight:600,fontSize:"0.85rem",color:"#111827"}},{children:l}))]})),t(a,e({sx:{flex:1,p:2,overflowY:"auto"}},{children:r(a,e({sx:{border:"1px solid #E5E7EB",borderRadius:"8px",p:1.5}},{children:[t(d,e({sx:{fontWeight:600,fontSize:"0.8rem",color:"#111827",mb:.75}},{children:"Description"})),t(d,e({sx:{fontSize:"0.73rem",color:"#6B7280",lineHeight:1.6}},{children:u}))]}))}))]})),r(a,e({sx:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"}},{children:[r(a,e({sx:{px:2,py:1.25,borderBottom:"1px solid #E5E7EB",display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[t(d,e({sx:{fontWeight:600,fontSize:"0.85rem",color:"#111827"}},{children:"Prompt Preview"})),t(w,{isDarkMode:F,onChange:L})]})),t(a,e({sx:{flex:1,minHeight:0,p:1.5}},{children:t(C,{content:p,selectedTag:v,highlightVariable:k,isDarkMode:F,height:"100%",fontSize:13})}))]}))]}))]}))]})};export{y as default};
1
+ import{__assign as e}from"tslib";import{jsxs as r,Fragment as o,jsx as t}from"react/jsx-runtime";import{useState as i,useEffect as n,useRef as l}from"react";import{Box as a,Typography as d,Tooltip as s,Dialog as c,IconButton as f,Chip as h}from"@mui/material";import g from"@mui/icons-material/Close";import u from"@mui/icons-material/Fullscreen";import m from"@monaco-editor/react";import p from"@mui/icons-material/DarkMode";import b from"@mui/icons-material/LightMode";var x={base:"vs-dark",inherit:!0,rules:[{token:"tag",foreground:"714be3",fontStyle:"bold"},{token:"attribute.name",foreground:"87CEFA"},{token:"attribute.value",foreground:"98FB98"},{token:"variable",foreground:"00FFFF"},{token:"delimiter",foreground:"888888"},{token:"white",foreground:"AAAAAA"}],colors:{"editor.foreground":"#FFFFFF","editor.background":"#030202","editorLineNumber.foreground":"#858585","editorCursor.foreground":"#FFFFFF","editorIndentGuide.background":"#404040","editorIndentGuide.activeBackground":"#707070"}},v={base:"vs",inherit:!0,rules:[{token:"tag",foreground:"5928ED",fontStyle:"bold"},{token:"attribute.name",foreground:"AF00DB"},{token:"attribute.value",foreground:"008000"},{token:"variable",foreground:"B000B0"},{token:"delimiter",foreground:"808080"},{token:"white",foreground:"000000"}],colors:{"editor.foreground":"#000000","editor.background":"#FFFFFF","editorLineNumber.foreground":"#999999","editorCursor.foreground":"#000000","editorIndentGuide.background":"#CCCCCC","editorIndentGuide.activeBackground":"#999999"}},k=function(r){var o=r.isDarkMode,i=r.onChange;return t(a,e({onClick:function(){return i(!o)},sx:{width:52,height:24,borderRadius:"12px",bgcolor:o?"#5928ed":"#f0f0f0",border:"1px solid",borderColor:o?"#5928ed":"#d1d5db",display:"flex",alignItems:"center",px:.4,cursor:"pointer",transition:"all 0.2s",justifyContent:o?"flex-end":"flex-start"}},{children:t(a,e({sx:{width:18,height:18,borderRadius:"50%",bgcolor:o?"#1e1e2e":"#f59e0b",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s"}},{children:t(o?p:b,{sx:{fontSize:11,color:"#fff"}})}))}))},w=function(i){var d=i.content,s=i.selectedTag,c=i.highlightVariable,f=i.isDarkMode,h=i.height,g=void 0===h?250:h,u=i.fontSize,p=void 0===u?12:u,b=i.editorBackgroundColor,k=l(),w=l(),y=function(){return b?e(e({},x),{colors:e(e({},x.colors),{"editor.background":b})}):x};return n(function(){if(s&&k.current&&w.current){var e=k.current,r=e.getModel();if(r){for(var o=r.getValue().split("\n"),t=-1,i=0;i<o.length;i++){var n=o[i].match(/<([^\s>\/]+(?:\s[^\s>\/]+)*)/);if(n&&n[1].trim().toLowerCase()===s.toLowerCase()){t=i+1;break}}if(t>0){var l=t,a="</".concat(s.toLowerCase(),">");for(i=t;i<o.length;i++)if(o[i].toLowerCase().includes(a)){l=i+1;break}e.setSelection(new w.current.Selection(t,1,t,1)),e.trigger(null,"editor.unfold",{}),e.revealLineInCenterIfOutsideViewport(t);var d=e.deltaDecorations([],[{range:new w.current.Range(t,1,l,o[l-1].length+1),options:{isWholeLine:!0,className:"promptemon-highlight",inlineClassName:"promptemon-highlight"}}]);setTimeout(function(){return e.deltaDecorations(d,[])},2e3)}}}},[s]),n(function(){if(c&&k.current&&w.current){var e=k.current,r=e.getModel();if(r){for(var o=r.getValue().split("\n"),t=[],i=0;i<o.length;i++)for(var n=o[i].indexOf(c);-1!==n;)t.push(new w.current.Range(i+1,n+1,i+1,n+c.length+1)),n=o[i].indexOf(c,n+1);if(0!==t.length){e.revealLineInCenterIfOutsideViewport(t[0].startLineNumber);var l=e.deltaDecorations([],t.map(function(e){return{range:e,options:{inlineClassName:"promptemon-variable-highlight"}}}));setTimeout(function(){return e.deltaDecorations(l,[])},2e3)}}}},[c]),n(function(){w.current&&w.current.editor.setTheme(f?"promptemonDark":"promptemonLight")},[f]),r(o,{children:[t("style",{children:"\n .promptemon-highlight { background-color: rgba(89, 40, 237, 0.15); }\n .promptemon-variable-highlight { background-color: rgba(0, 255, 255, 0.2); border-radius: 2px; }\n "}),r(a,e({sx:{width:"100%",height:g,display:"flex",flexDirection:"column"}},{children:[t(a,{sx:{width:"100%",height:20,bgcolor:f?b||"#030202":"#fff",borderTopLeftRadius:8,borderTopRightRadius:8}}),t(a,e({sx:{flex:1,minHeight:0,overflow:"hidden"}},{children:t(m,{onMount:function(e,r){k.current=e,w.current=r,r.editor.defineTheme("promptemonDark",y()),r.editor.defineTheme("promptemonLight",v),r.editor.setTheme(f?"promptemonDark":"promptemonLight"),r.languages.register({id:"promptemonLang"}),r.languages.setMonarchTokensProvider("promptemonLang",{tokenizer:{root:[[/(<)([a-zA-Z0-9\-]+)(\s*)/,["delimiter","tag","white"],"@tagBody"],[/(<\/)([a-zA-Z0-9\-]+)(\s*)(>)/,["delimiter","tag","white","delimiter"]],[/{{[^}]+}}/,"variable"]],tagBody:[[/[a-zA-Z0-9\:\-]+(?=\=)/,"attribute.name"],[/=/,"delimiter"],[/(".*?"|'.*?')/,"attribute.value"],[/\s+/,"white"],[/(\/?>)/,{token:"delimiter",next:"@pop"}]]}}),r.languages.registerFoldingRangeProvider("promptemonLang",{provideFoldingRanges:function(e){var r=e.getLinesContent(),o=[],t=[];return r.forEach(function(e,r){var i=r+1,n=e.match(/<([a-zA-Z0-9\-]+)(\s[^>]*)?>/),l=e.match(/<\/([a-zA-Z0-9\-]+)>/);if(n&&!e.includes("/>")&&t.push({tag:n[1],start:i}),l)for(var a=l[1],d=t.length-1;d>=0;d--)if(t[d].tag===a){o.push({start:t[d].start,end:i}),t.splice(d,1);break}}),o}})},beforeMount:function(e){e.editor.defineTheme("promptemonDark",y()),e.editor.defineTheme("promptemonLight",v),e.editor.setTheme(f?"promptemonDark":"promptemonLight")},theme:f?"promptemonDark":"promptemonLight",value:d,language:"promptemonLang",onChange:function(){},options:{fontSize:p,minimap:{enabled:!1},wordWrap:"on",lineNumbers:"on",readOnly:!0,domReadOnly:!0,scrollBeyondLastLine:!1,padding:{top:4,bottom:12},folding:!0,automaticLayout:!0,scrollbar:{vertical:"visible",horizontal:"visible",verticalScrollbarSize:8}}})})),t(a,{sx:{width:"100%",height:20,bgcolor:f?b||"#030202":"#fff",borderBottomLeftRadius:8,borderBottomRightRadius:8}})]}))]})},y=function(l){var m=l.title,p=l.description,b=l.content,x=l.height,v=void 0===x?250:x,y=l.selectedTag,C=l.highlightVariable,F=l.className,L=l.style,z=l.showThemeToggle,B=void 0===z||z,S=l.theme,D=void 0===S?"dark":S,R=l.editorBackgroundColor,E=l.fontSize,T=void 0===E?12:E,I=l.titleFontSize,A=l.titleStyle,M=i("dark"===D),W=M[0],N=M[1],V=i(!1),P=V[0],j=V[1];return n(function(){N("dark"===D)},[D]),r(o,{children:[r(a,e({className:F,style:L,sx:{border:"1px solid #e5e7eb",borderRadius:"8px",overflow:"hidden"}},{children:[r(a,e({sx:{px:1.5,py:.75,bgcolor:W?R||"#030202":"#f9fafb",borderBottom:W?"1px solid #333":"1px solid #e5e7eb",display:"flex",alignItems:"center",justify:"space-between"}},{children:[t(d,e({style:A,sx:{fontSize:I||"0.72rem",color:W?"#e5e7eb":"#374151",fontWeight:600}},{children:m})),r(a,e({sx:{display:"flex",alignItems:"center",gap:.75}},{children:[B&&t(k,{isDarkMode:W,onChange:N}),t(s,e({title:"Fullscreen",placement:"top"},{children:t(a,e({onClick:function(){return j(!0)},sx:{cursor:"pointer",display:"flex",alignItems:"center",p:.3,borderRadius:"4px","&:hover":{bgcolor:W?"#333":"#e5e7eb"}}},{children:t(u,{sx:{fontSize:"0.9rem",color:W?"#9ca3af":"#6b7280"}})}))}))]}))]})),t(a,e({sx:{height:v,bgcolor:W?R||"#030202":"#fff"}},{children:t(w,{content:b,selectedTag:y,highlightVariable:C,isDarkMode:W,height:v,fontSize:T,editorBackgroundColor:R})}))]})),r(c,e({open:P,onClose:function(){return j(!1)},maxWidth:!1,PaperProps:{sx:{width:"82vw",height:"80vh",maxWidth:"none",borderRadius:"12px",overflow:"hidden",display:"flex",flexDirection:"column"}}},{children:[r(a,e({sx:{px:2.5,py:1.5,borderBottom:"1px solid #E5E7EB",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0}},{children:[t(d,e({sx:{fontWeight:700,fontSize:"1rem",color:"#111827"}},{children:m})),t(f,e({size:"small",onClick:function(){return j(!1)}},{children:t(g,{sx:{fontSize:"1.1rem",color:"#6B7280"}})}))]})),r(a,e({sx:{flex:1,display:"flex",overflow:"hidden",minHeight:0}},{children:[p&&r(a,e({sx:{width:"35%",flexShrink:0,borderRight:"1px solid #E5E7EB",display:"flex",flexDirection:"column",overflow:"hidden"}},{children:[r(a,e({sx:{px:2,py:1.25,borderBottom:"1px solid #E5E7EB",display:"flex",alignItems:"center",gap:1}},{children:[t(h,{label:"APB",size:"small",sx:{bgcolor:"#f1f5f9",color:"#475569",fontWeight:700,fontSize:10,height:20,borderRadius:1}}),t(d,e({sx:{fontWeight:600,fontSize:"0.85rem",color:"#111827"}},{children:m}))]})),t(a,e({sx:{flex:1,p:2,overflowY:"auto"}},{children:r(a,e({sx:{border:"1px solid #E5E7EB",borderRadius:"8px",p:1.5}},{children:[t(d,e({sx:{fontWeight:600,fontSize:"0.8rem",color:"#111827",mb:.75}},{children:"Description"})),t(d,e({sx:{fontSize:"0.73rem",color:"#6B7280",lineHeight:1.6}},{children:p}))]}))}))]})),r(a,e({sx:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"}},{children:[r(a,e({sx:{px:2,py:1.25,borderBottom:"1px solid #E5E7EB",display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[t(d,e({sx:{fontWeight:600,fontSize:"0.85rem",color:"#111827"}},{children:"Prompt Preview"})),B&&t(k,{isDarkMode:W,onChange:N})]})),t(a,e({sx:{flex:1,minHeight:0,p:1.5}},{children:t(w,{content:b,selectedTag:y,highlightVariable:C,isDarkMode:W,height:"100%",fontSize:13})}))]}))]}))]}))]})};export{y as default};
2
2
  //# sourceMappingURL=PromptemonBlockViewer.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e,__spreadArray as n}from"tslib";import{jsxs as o,jsx as t,Fragment as i}from"react/jsx-runtime";import{useState as r,useRef as l,useEffect as d}from"react";import{Box as a,Stack as c,IconButton as s,Typography as u,Button as f,Tooltip as p,Chip as h,TextField as g,Accordion as m,AccordionSummary as x,AccordionDetails as b,Select as v,MenuItem as y,Divider as w,Dialog as S}from"@mui/material";import z from"@mui/icons-material/ExpandMore";import C from"@mui/icons-material/EditOutlined";import _ from"@mui/icons-material/Close";import k from"@mui/icons-material/ArrowBack";import I from"@mui/icons-material/NavigateBefore";import W from"@mui/icons-material/NavigateNext";import R from"@mui/icons-material/InfoOutlined";import A from"@mui/icons-material/AutoFixHighOutlined";import B from"@mui/icons-material/Check";import F from"@mui/icons-material/Add";import L from"@mui/icons-material/DeleteOutline";import D from"@monaco-editor/react";import*as M from"monaco-editor";import T from"@mui/icons-material/DarkMode";import V from"@mui/icons-material/LightMode";var E={base:"vs-dark",inherit:!0,rules:[{token:"tag",foreground:"714be3",fontStyle:"bold"},{token:"attribute.name",foreground:"87CEFA"},{token:"attribute.value",foreground:"98FB98"},{token:"variable",foreground:"00FFFF"},{token:"delimiter",foreground:"888888"},{token:"white",foreground:"AAAAAA"}],colors:{"editor.foreground":"#FFFFFF","editor.background":"#030202","editorLineNumber.foreground":"#858585","editorCursor.foreground":"#FFFFFF","editorIndentGuide.background":"#404040","editorIndentGuide.activeBackground":"#707070"}},O={base:"vs",inherit:!0,rules:[{token:"tag",foreground:"5928ED",fontStyle:"bold"},{token:"attribute.name",foreground:"AF00DB"},{token:"attribute.value",foreground:"008000"},{token:"variable",foreground:"B000B0"},{token:"delimiter",foreground:"808080"},{token:"white",foreground:"000000"}],colors:{"editor.foreground":"#000000","editor.background":"#FFFFFF","editorLineNumber.foreground":"#999999","editorCursor.foreground":"#000000","editorIndentGuide.background":"#CCCCCC","editorIndentGuide.activeBackground":"#999999"}},P=function(n){var i=n.description,c=r(!1),s=c[0],f=c[1],p=r(!1),h=p[0],g=p[1],m=l(null);return d(function(){var e=m.current;e&&g(e.scrollHeight>e.clientHeight+1)},[i,s]),o(a,e({sx:{mt:1.5,border:"1px solid #e5e7eb",borderRadius:2,bgcolor:"#fff",display:"flex",flexDirection:"column",px:1.25,py:1}},{children:[t(u,e({ref:m,component:"div",sx:e({fontSize:11,color:"#6b7280",lineHeight:1.5,overflowY:s?"auto":"hidden",maxHeight:s?"calc(1.6em * 5)":"calc(1.6em * 3)",whiteSpace:"normal",display:s?"block":"-webkit-box"},s?{}:{WebkitBoxOrient:"vertical",WebkitLineClamp:3})},{children:i})),h&&t(u,e({component:"span",onClick:function(){return f(function(e){return!e})},sx:{mt:.75,alignSelf:"flex-end",fontSize:10,color:"#7c3aed",cursor:"pointer",fontWeight:500}},{children:s?"View less":"View more"}))]}))},j=function(n){var i=n.value,l=n.onChange,d=n.onDelete,f=r(!1),p=f[0],h=f[1];return o(a,e({sx:{display:"flex",alignItems:"flex-start",gap:1,p:1,border:"1px solid #e5e7eb",borderRadius:"8px",bgcolor:"#fff"}},{children:[t(a,e({sx:{width:18,height:18,borderRadius:"4px",bgcolor:"#f1f5f9",display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,color:"#64748b",flexShrink:0,mt:.1}},{children:"a"})),p?t(g,{autoFocus:!0,value:i,onChange:function(e){return l(e.target.value)},onBlur:function(){return h(!1)},size:"small",fullWidth:!0,multiline:!0,sx:{"& .MuiOutlinedInput-input":{fontSize:12.5}}}):t(u,e({sx:{fontSize:12.5,color:"#374151",lineHeight:1.55,flex:1}},{children:i})),o(c,e({direction:"row",gap:.25,sx:{flexShrink:0}},{children:[t(s,e({size:"small",onClick:function(){return h(!0)},sx:{color:"#6b7280"}},{children:t(C,{sx:{fontSize:14}})})),t(s,e({size:"small",onClick:d,sx:{color:"#dc2626"}},{children:t(L,{sx:{fontSize:14}})}))]}))]}))},N=function(n){var o=n.isDarkMode,i=n.onChange;return t(a,e({onClick:function(){return i(!o)},sx:{width:52,height:24,borderRadius:"12px",bgcolor:o?"#5928ed":"#f0f0f0",border:"1px solid",borderColor:o?"#5928ed":"#d1d5db",display:"flex",alignItems:"center",px:.4,cursor:"pointer",transition:"all 0.2s",justifyContent:o?"flex-end":"flex-start"}},{children:t(a,e({sx:{width:18,height:18,borderRadius:"50%",bgcolor:o?"#1e1e2e":"#f59e0b",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s"}},{children:t(o?T:V,{sx:{fontSize:11,color:"#fff"}})}))}))},G=function(n){var r=n.content,c=n.selectedTag,s=n.highlightVariable,u=n.isDarkMode,f=n.height,p=void 0===f?250:f,h=n.fontSize,g=void 0===h?12:h,m=l(),x=l();return d(function(){if(c&&m.current&&x.current){var e=m.current,n=e.getModel();if(n){for(var o=n.getValue().split("\n"),t=-1,i=0;i<o.length;i++){var r=o[i].match(/<([^\s>\/]+(?:\s[^\s>\/]+)*)/);if(r&&r[1].trim().toLowerCase()===c.toLowerCase()){t=i+1;break}}if(t>0){var l=t,d="</".concat(c.toLowerCase(),">");for(i=t;i<o.length;i++)if(o[i].toLowerCase().includes(d)){l=i+1;break}e.setSelection(new x.current.Selection(t,1,t,1)),e.trigger(null,"editor.unfold",{}),e.revealLineInCenterIfOutsideViewport(t);var a=e.deltaDecorations([],[{range:new x.current.Range(t,1,l,o[l-1].length+1),options:{isWholeLine:!0,className:"promptemon-viewer-highlight",inlineClassName:"promptemon-viewer-highlight"}}]);setTimeout(function(){return e.deltaDecorations(a,[])},2e3)}}}},[c]),d(function(){if(s&&m.current&&x.current){var e=m.current,n=e.getModel();if(n){for(var o=n.getValue().split("\n"),t=[],i=0;i<o.length;i++)for(var r=o[i].indexOf(s);-1!==r;)t.push(new M.Range(i+1,r+1,i+1,r+s.length+1)),r=o[i].indexOf(s,r+1);if(0!==t.length){e.revealLineInCenterIfOutsideViewport(t[0].startLineNumber);var l=e.deltaDecorations([],t.map(function(e){return{range:e,options:{inlineClassName:"promptemon-viewer-variable-highlight"}}}));setTimeout(function(){return e.deltaDecorations(l,[])},2e3)}}}},[s]),d(function(){x.current&&x.current.editor.setTheme(u?"promptemonViewerDark":"promptemonViewerLight")},[u]),o(i,{children:[t("style",{children:"\n .promptemon-viewer-highlight { background-color: rgba(89, 40, 237, 0.15); }\n .promptemon-viewer-variable-highlight { background-color: rgba(0, 255, 255, 0.2); border-radius: 2px; }\n "}),o(a,e({sx:{width:"100%",height:p,display:"flex",flexDirection:"column"}},{children:[t(a,{sx:{width:"100%",height:20,bgcolor:u?"#030202":"#fff",borderTopLeftRadius:8,borderTopRightRadius:8}}),t(a,e({sx:{flex:1,minHeight:0,overflow:"hidden"}},{children:t(D,{onMount:function(e,n){m.current=e,x.current=n,n.editor.defineTheme("promptemonViewerDark",E),n.editor.defineTheme("promptemonViewerLight",O),n.editor.setTheme(u?"promptemonViewerDark":"promptemonViewerLight"),n.languages.register({id:"promptemonViewerLang"}),n.languages.setMonarchTokensProvider("promptemonViewerLang",{tokenizer:{root:[[/(<)([a-zA-Z0-9\-]+)(\s*)/,["delimiter","tag","white"],"@tagBody"],[/(<\/)([a-zA-Z0-9\-]+)(\s*)(>)/,["delimiter","tag","white","delimiter"]],[/{{[^}]+}}/,"variable"]],tagBody:[[/[a-zA-Z0-9\:\-]+(?=\=)/,"attribute.name"],[/=/,"delimiter"],[/(".*?"|'.*?')/,"attribute.value"],[/\s+/,"white"],[/(\/?>)/,{token:"delimiter",next:"@pop"}]]}}),n.languages.registerFoldingRangeProvider("promptemonViewerLang",{provideFoldingRanges:function(e){var n=e.getLinesContent(),o=[],t=[];return n.forEach(function(e,n){var i=n+1,r=e.match(/<([a-zA-Z0-9\-]+)(\s[^>]*)?>/),l=e.match(/<\/([a-zA-Z0-9\-]+)>/);if(r&&!e.includes("/>")&&t.push({tag:r[1],start:i}),l)for(var d=l[1],a=t.length-1;a>=0;a--)if(t[a].tag===d){o.push({start:t[a].start,end:i}),t.splice(a,1);break}}),o}})},beforeMount:function(e){e.editor.defineTheme("promptemonViewerDark",E),e.editor.defineTheme("promptemonViewerLight",O),e.editor.setTheme(u?"promptemonViewerDark":"promptemonViewerLight")},theme:u?"promptemonViewerDark":"promptemonViewerLight",value:r,language:"promptemonViewerLang",onChange:function(){},options:{fontSize:g,minimap:{enabled:!1},wordWrap:"on",lineNumbers:"on",readOnly:!0,domReadOnly:!0,scrollBeyondLastLine:!1,padding:{top:4,bottom:12},folding:!0,automaticLayout:!0,scrollbar:{vertical:"visible",horizontal:"visible",verticalScrollbarSize:8}}})})),t(a,{sx:{width:"100%",height:20,bgcolor:u?"#030202":"#fff",borderBottomLeftRadius:8,borderBottomRightRadius:8}})]}))]})},H=function(i){var l,d,k,I,W=i.block,A=i.isExtracted,D=i.isSaved,M=i.showEditMode,T=i.onBlockUpdate,V=i.onTagSelect,E=i.onVariableSelect,O=i.categories,N=i.subCategories,G=i.selectedCategoryId,H=i.selectedSubCategoryId,Z=i.onCategoryChange,U=i.onSubCategoryChange,Y=r(!0),q=Y[0],J=Y[1],K=r(!0),Q=K[0],X=K[1],$=r(!0),ee=$[0],ne=$[1],oe=r(!0),te=oe[0],ie=oe[1],re=r(!1),le=re[0],de=re[1],ae=r(!0),ce=ae[0],se=ae[1],ue=r(!0),fe=ue[0],pe=ue[1],he=r(!1),ge=he[0],me=he[1],xe=r(!1),be=xe[0],ve=xe[1],ye=r(!1),we=ye[0],Se=ye[1],ze=r((null==W?void 0:W.title)||""),Ce=ze[0],_e=ze[1],ke=r((null==W?void 0:W.short_description)||""),Ie=ke[0],We=ke[1],Re=r((null==W?void 0:W.members)||[]),Ae=Re[0],Be=Re[1],Fe=r(Array.isArray(null==W?void 0:W.when_to_apply)?W.when_to_apply:(null==W?void 0:W.when_to_apply)?[W.when_to_apply]:[]),Le=Fe[0],De=Fe[1],Me=r(Array.isArray(null==W?void 0:W.when_not_to_apply)?W.when_not_to_apply:(null==W?void 0:W.when_not_to_apply)?[W.when_not_to_apply]:[]),Te=Me[0],Ve=Me[1],Ee=r(!1),Oe=Ee[0],Pe=Ee[1],je=r(""),Ne=je[0],Ge=je[1],He=r(""),Ze=He[0],Ue=He[1],Ye={boxShadow:"none",border:"1px solid #e5e7eb",borderRadius:"8px !important",mb:1.5,"&:before":{display:"none"},"&.Mui-expanded":{margin:"0 0 12px 0"}},qe={minHeight:44,px:2,borderRadius:2,"&.Mui-expanded":{minHeight:44},"& .MuiAccordionSummary-content":{my:"10px"}};return o(a,e({sx:{width:820,flexShrink:0,display:"flex",flexDirection:"column",overflow:"hidden",borderRight:"1px solid #e5e7eb"}},{children:[o(a,e({sx:{px:2.5,py:2,borderBottom:"1px solid #e5e7eb"}},{children:[o(c,e({direction:"row",alignItems:"center",justifyContent:"space-between"},{children:[o(c,e({direction:"row",alignItems:"center",gap:1,sx:{flex:1,minWidth:0}},{children:[t(p,e({title:"Functional Prompt Block",placement:"top"},{children:t(h,{label:"FPB",size:"small",sx:{bgcolor:"#f1f5f9",color:"#475569",fontWeight:700,fontSize:11,height:22,borderRadius:1}})})),we?t(g,{value:Ce,onChange:function(e){return _e(e.target.value)},size:"small",fullWidth:!0,sx:{"& .MuiOutlinedInput-input":{fontSize:15,fontWeight:700,py:.5}}}):t(u,e({sx:{fontWeight:700,fontSize:15,color:"#111827"}},{children:(null==W?void 0:W.title)||"—"}))]})),we?o(c,e({direction:"row",gap:.5},{children:[t(s,e({size:"small",sx:{color:"#6b7280"},onClick:function(){return Se(!1)}},{children:t(_,{sx:{fontSize:16}})})),t(s,e({size:"small",sx:{color:"#16a34a"},onClick:function(){T(e(e({},W),{title:Ce,short_description:Ie,members:Ae,when_to_apply:Le,when_not_to_apply:Te})),Se(!1)}},{children:t(B,{sx:{fontSize:16}})}))]})):!D&&M&&t(s,e({size:"small",sx:{color:"#6b7280"},onClick:function(){_e((null==W?void 0:W.title)||""),We((null==W?void 0:W.short_description)||""),Be((null==W?void 0:W.members)||[]),De(Array.isArray(null==W?void 0:W.when_to_apply)?W.when_to_apply:(null==W?void 0:W.when_to_apply)?[W.when_to_apply]:[]),Ve(Array.isArray(null==W?void 0:W.when_not_to_apply)?W.when_not_to_apply:(null==W?void 0:W.when_not_to_apply)?[W.when_not_to_apply]:[]),Se(!0)}},{children:t(C,{sx:{fontSize:16}})}))]})),we&&t(u,e({sx:{fontSize:11,color:"#5928ed",mt:.5}},{children:"Editing — changes won't be saved until you confirm"})),we?t(g,{value:Ie,onChange:function(e){return We(e.target.value)},size:"small",fullWidth:!0,multiline:!0,minRows:3,sx:{mt:1.5,"& .MuiOutlinedInput-input":{fontSize:12}}}):t(P,{description:(null==W?void 0:W.short_description)||"—"}),o(a,e({sx:{mt:1.5,border:"0.5px solid #d1d5db",borderRadius:"8px",display:"flex",overflow:"hidden"}},{children:[t(a,e({sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",borderRight:"1px solid #d1d5db",p:.5}},{children:o(c,e({direction:"row",alignItems:"center",gap:1},{children:[t(u,e({sx:{fontSize:10,color:"#87898d"}},{children:"Total APBs :"})),t(u,e({sx:{fontSize:10,fontWeight:700,color:"#5f5f5f"}},{children:(null===(l=null==W?void 0:W.members)||void 0===l?void 0:l.length)||0}))]}))})),t(a,e({sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",p:.5}},{children:o(c,e({direction:"row",alignItems:"center",gap:1},{children:[t(u,e({sx:{fontSize:10,color:"#87898d"}},{children:"Total Lines :"})),t(u,e({sx:{fontSize:10,fontWeight:700,color:"#5f5f5f"}},{children:(null===(d=null==W?void 0:W.members)||void 0===d?void 0:d.reduce(function(e,n){var o,t;return e+((null!==(o=n.end_line)&&void 0!==o?o:0)-(null!==(t=n.start_line)&&void 0!==t?t:0)+1)},0))||0}))]}))}))]}))]})),o(a,e({sx:{flex:1,overflow:"auto",px:2,py:2,"&::-webkit-scrollbar":{width:4},"&::-webkit-scrollbar-thumb":{bgcolor:"#e5e7eb",borderRadius:2}}},{children:[o(m,e({expanded:q,onChange:function(){return J(function(e){return!e})},sx:Ye,disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:18}}),sx:qe},{children:t(u,e({sx:{fontSize:13,fontWeight:600,color:"#374151"}},{children:"Categories"}))})),t(b,e({sx:{pt:0,px:2,pb:2}},{children:o(c,e({gap:1.5},{children:[o(a,{children:[t(u,e({sx:{fontSize:12,color:"#6b7280",mb:.5}},{children:"Category"})),we?t(v,e({fullWidth:!0,size:"small",value:G,onChange:function(e){Z(e.target.value),U("")},sx:{fontSize:13,borderRadius:1.5,"& fieldset":{borderColor:"#e5e7eb"}}},{children:O.map(function(n){return t(y,e({value:n.category_id},{children:n.category_name}),n.category_id)})})):t(g,{fullWidth:!0,size:"small",value:(null===(k=O.find(function(e){return e.category_id===G}))||void 0===k?void 0:k.category_name)||"—",InputProps:{readOnly:!0},sx:{"& .MuiOutlinedInput-root":{fontSize:13,borderRadius:1.5,"& fieldset":{borderColor:"#e5e7eb"}}}})]}),o(a,{children:[t(u,e({sx:{fontSize:12,color:"#6b7280",mb:.5}},{children:"Sub-Category"})),we?t(v,e({fullWidth:!0,size:"small",value:H,onChange:function(e){return U(e.target.value)},disabled:!G,sx:{fontSize:13,borderRadius:1.5,"& fieldset":{borderColor:"#e5e7eb"}}},{children:N.filter(function(e){return e.category_id===G}).map(function(n){return t(y,e({value:n.sub_category_id},{children:n.sub_category_name}),n.sub_category_id)})})):t(g,{fullWidth:!0,size:"small",value:(null===(I=N.find(function(e){return e.sub_category_id===H}))||void 0===I?void 0:I.sub_category_name)||"—",InputProps:{readOnly:!0},sx:{"& .MuiOutlinedInput-root":{fontSize:13,borderRadius:1.5,"& fieldset":{borderColor:"#e5e7eb"}}}})]})]}))}))]})),o(m,e({expanded:Q,onChange:function(){return X(function(e){return!e})},sx:Ye,disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:18}}),sx:qe},{children:t(u,e({sx:{fontSize:13,fontWeight:600,color:"#374151"}},{children:"Atomic Prompt Blocks (APBs)"}))})),o(b,e({sx:{pt:0,px:1,pb:2}},{children:[t(c,e({gap:1},{children:(we?Ae:(null==W?void 0:W.members)||[]).map(function(n,i){return o(a,e({sx:{px:2,py:1,borderRadius:2,bgcolor:"#fff"}},{children:[o(a,e({sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",mb:1,gap:1}},{children:[o(u,e({sx:{fontSize:14,fontWeight:500,color:"#111827"}},{children:[i+1,". ",n.section_name]})),we?t(s,e({size:"small",onClick:function(){return Be(function(e){return e.filter(function(e,n){return n!==i})})},sx:{color:"#dc2626",flexShrink:0}},{children:t(L,{sx:{fontSize:16}})})):t(a,e({onClick:function(){return V(n.section_name.split("_").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}).join("_"))},sx:{fontSize:14,color:"#475569",cursor:"pointer",flexShrink:0}},{children:"↗"}))]})),t(u,e({sx:{fontSize:12,lineHeight:1.5,color:"#64748b"}},{children:n.reason_for_inclusion})),A&&(r=n.segments||[],0===r.length?null:t(a,e({sx:{mt:1}},{children:t(a,e({sx:{display:"flex",flexWrap:"wrap",gap:1}},{children:r.map(function(e,n){return t(h,{clickable:!0,onClick:function(){return E(e.segmentized_text)},label:e.segmentized_text,sx:{borderRadius:1,bgcolor:"#eff6ff",color:"#3b82f6",border:"1px dashed #bfdbfe"}},n)})}))}))),t(w,{sx:{mt:2}})]}),i);var r})})),we&&o(a,e({onClick:function(){Ge(""),Ue(""),Pe(!0)},sx:{mt:1,display:"flex",alignItems:"center",justifyContent:"center",gap:.5,py:1,border:"1px dashed #d1d5db",borderRadius:1.5,cursor:"pointer",color:"#5928ed",fontSize:13,fontWeight:600,"&:hover":{bgcolor:"#f5f0ff"}}},{children:[t(F,{sx:{fontSize:16}})," Add APB"]}))]}))]})),o(m,e({expanded:ee,onChange:function(){return ne(function(e){return!e})},sx:Ye,disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:18}}),sx:qe},{children:o(u,e({sx:{fontSize:14,fontWeight:600,color:"#374151",display:"flex",alignItems:"center",flexDirection:"row"}},{children:["Applicability ",t("span",e({style:{color:"#94a3b8",fontWeight:400,fontSize:10,marginLeft:"12px"}},{children:"• When to apply / When not to apply"}))]}))})),o(b,e({sx:{pt:0,px:1.5,pb:1.5}},{children:[o(m,e({expanded:te,onChange:function(){return ie(function(e){return!e})},sx:{boxShadow:"none",border:"1px solid #e5e7eb",borderRadius:"6px !important",mb:1,"&:before":{display:"none"},"&.Mui-expanded":{margin:"0 0 8px 0"}},disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:16}}),sx:e(e({},qe),{bgcolor:"#f9fafb",borderRadius:"6px"})},{children:t(u,e({sx:{fontSize:12.5,fontWeight:500,color:"#374151"}},{children:"When to Apply this FPB"}))})),t(b,e({sx:{pt:.5,px:2,pb:1.5}},{children:o(c,e({gap:.75},{children:[(we?Le:Array.isArray(null==W?void 0:W.when_to_apply)?W.when_to_apply:(null==W?void 0:W.when_to_apply)?[W.when_to_apply]:["— Not yet available"]).map(function(n,i){return we?t(j,{value:n,onChange:function(e){return De(function(n){return n.map(function(n,o){return o===i?e:n})})},onDelete:function(){return De(function(e){return e.filter(function(e,n){return n!==i})})}},i):o(c,e({direction:"row",gap:1,alignItems:"flex-start"},{children:[o(u,e({sx:{fontSize:12,color:"#374151",fontWeight:700,mt:.1}},{children:[i+1,"."]})),t(u,e({sx:{fontSize:12.5,color:"#374151",lineHeight:1.55}},{children:n}))]}),i)}),we&&o(a,e({onClick:function(){return De(function(e){return n(n([],e,!0),[""],!1)})},sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:.5,py:.75,border:"1px dashed #d1d5db",borderRadius:1.5,cursor:"pointer",color:"#5928ed",fontSize:12.5,fontWeight:600,"&:hover":{bgcolor:"#f5f0ff"}}},{children:[t(F,{sx:{fontSize:15}})," Add When to Apply"]}))]}))}))]})),o(m,e({expanded:le,onChange:function(){return de(function(e){return!e})},sx:{boxShadow:"none",border:"1px solid #e5e7eb",borderRadius:"6px !important","&:before":{display:"none"}},disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:16}}),sx:e(e({},qe),{bgcolor:"#f9fafb",borderRadius:"6px"})},{children:t(u,e({sx:{fontSize:12.5,fontWeight:500,color:"#374151"}},{children:"When NOT to Apply this FPB"}))})),t(b,e({sx:{pt:.5,px:2,pb:1.5}},{children:we?o(c,e({gap:.75},{children:[Te.map(function(e,n){return t(j,{value:e,onChange:function(e){return Ve(function(o){return o.map(function(o,t){return t===n?e:o})})},onDelete:function(){return Ve(function(e){return e.filter(function(e,o){return o!==n})})}},n)}),o(a,e({onClick:function(){return Ve(function(e){return n(n([],e,!0),[""],!1)})},sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:.5,py:.75,border:"1px dashed #d1d5db",borderRadius:1.5,cursor:"pointer",color:"#5928ed",fontSize:12.5,fontWeight:600,"&:hover":{bgcolor:"#f5f0ff"}}},{children:[t(F,{sx:{fontSize:15}})," Add When NOT to Apply"]}))]})):Array.isArray(null==W?void 0:W.when_not_to_apply)||(null==W?void 0:W.when_not_to_apply)?t(c,e({gap:.75},{children:(Array.isArray(null==W?void 0:W.when_not_to_apply)?W.when_not_to_apply:[W.when_not_to_apply]).map(function(n,i){return o(c,e({direction:"row",gap:1,alignItems:"flex-start"},{children:[o(u,e({sx:{fontSize:12,color:"#374151",fontWeight:700,mt:.1}},{children:[i+1,"."]})),t(u,e({sx:{fontSize:12.5,color:"#374151",lineHeight:1.55}},{children:n}))]}),i)})})):t(u,e({sx:{fontSize:12.5,color:"#9ca3af",fontStyle:"italic"}},{children:"No conditions defined yet."}))}))]}))]}))]})),o(m,e({expanded:ce,onChange:function(){return se(function(e){return!e})},sx:Ye,disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:18}}),sx:qe},{children:o(u,e({sx:{fontSize:14,fontWeight:600,color:"#374151",display:"flex",alignItems:"center",flexDirection:"row"}},{children:["Specifications ",t("span",e({style:{color:"#94a3b8",fontWeight:400,fontSize:10,marginLeft:"12px"}},{children:"• Strict Rules / Input / Output"}))]}))})),t(b,e({sx:{pt:0,px:1.5,pb:1.5}},{children:[{label:"Guidelines",expanded:fe,setExpanded:pe,content:null==W?void 0:W.additional_guidelines},{label:"Input",expanded:ge,setExpanded:me,content:null},{label:"Output",expanded:be,setExpanded:ve,content:null}].map(function(n,i){var r=n.label,l=n.expanded,d=n.setExpanded,a=n.content;return o(m,e({expanded:l,onChange:function(){return d(function(e){return!e})},sx:{boxShadow:"none",border:"1px solid #e5e7eb",borderRadius:"6px !important",mb:i<2?1:0,"&:before":{display:"none"},"&.Mui-expanded":{margin:i<2?"0 0 8px 0":0}},disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:16}}),sx:e(e({},qe),{bgcolor:"#f9fafb",borderRadius:"6px"})},{children:o(c,e({direction:"row",alignItems:"center",gap:.5},{children:[t(u,e({sx:{fontSize:12.5,fontWeight:500,color:"#374151"}},{children:r})),"Guidelines"!==r&&t(R,{sx:{fontSize:13,color:"#9ca3af"}})]}))})),t(b,e({sx:{pt:.5,px:2,pb:1.5}},{children:t(u,e({sx:{fontSize:12.5,color:a?"#374151":"#9ca3af",fontStyle:a?"normal":"italic"}},{children:a||"No ".concat(r.toLowerCase()," defined yet.")}))}))]}),r)})}))]}))]})),o(S,e({open:Oe,onClose:function(){return Pe(!1)},maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px"}}},{children:[o(a,e({sx:{px:3,py:2,display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid #e5e7eb"}},{children:[t(u,e({sx:{fontWeight:700,fontSize:"1rem",color:"#111827"}},{children:"Add new APB"})),t(s,e({size:"small",onClick:function(){return Pe(!1)}},{children:t(_,{sx:{fontSize:"1.1rem",color:"#6b7280"}})}))]})),o(a,e({sx:{px:3,py:2.5,display:"flex",flexDirection:"column",gap:2}},{children:[o(a,{children:[t(u,e({sx:{fontSize:13,fontWeight:600,color:"#374151",mb:.75}},{children:"Title"})),t(g,{fullWidth:!0,size:"small",placeholder:"Specify the title of APB",value:Ne,onChange:function(e){return Ge(e.target.value)}})]}),o(a,{children:[t(u,e({sx:{fontSize:13,fontWeight:600,color:"#374151",mb:.75}},{children:"Description"})),t(g,{fullWidth:!0,size:"small",multiline:!0,minRows:3,placeholder:"Describe the APB",value:Ze,onChange:function(e){return Ue(e.target.value)}})]})]})),o(a,e({sx:{px:3,py:2,display:"flex",justifyContent:"flex-end",gap:1,borderTop:"1px solid #e5e7eb"}},{children:[t(f,e({variant:"outlined",onClick:function(){return Pe(!1)},sx:{textTransform:"none",borderColor:"#d1d5db",color:"#374151"}},{children:"Cancel"})),t(f,e({variant:"contained",onClick:function(){Be(function(e){return n(n([],e,!0),[{section_name:Ne,reason_for_inclusion:Ze,content:""}],!1)}),Pe(!1)},sx:{textTransform:"none",bgcolor:"#5928ed","&:hover":{bgcolor:"#4c1d95"}}},{children:"Save"}))]}))]}))]}))},Z=function(n){var i,l,d,p,h,g=n.block,m=n.onBlockUpdate,x=n.isExtracting,b=n.isExtracted,v=n.onExtractSegments,y=n.isSaving,w=n.isSaved,S=n.onSave,z=n.onBack,C=n.title,R=void 0===C?"FPB Promptemon":C,B=n.categories,F=n.subCategories,L=n.selectedCategoryId,D=n.selectedSubCategoryId,M=n.onCategoryChange,T=n.onSubCategoryChange,V=n.showEditMode,E=void 0===V||V,O=n.showExtractSegments,P=void 0===O||O,j=r(1),Z=j[0],U=j[1],Y=r(!0),q=Y[0],J=Y[1],K=r(""),Q=K[0],X=K[1],$=r(""),ee=$[0],ne=$[1],oe=(null===(i=null==g?void 0:g.members)||void 0===i?void 0:i.map(function(e){if(!b||!e.segments||0===e.segments.length)return e.content||"";var n=e.content||"";return e.segments.forEach(function(e){e.raw_text&&e.segmentized_text&&(n=n.split(e.raw_text).join(e.segmentized_text))}),n}).join("\n\n"))||"";return o(a,e({sx:{width:"100%",height:"100%",display:"flex",flexDirection:"column",bgcolor:"#fff",overflow:"hidden"}},{children:[o(a,e({sx:{px:2.5,py:1.5,borderBottom:"1px solid #e5e7eb",display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#fff",flexShrink:0}},{children:[o(c,e({direction:"row",alignItems:"center",gap:1},{children:[t(s,e({size:"small",sx:{color:"#6b7280"},onClick:z},{children:t(k,{sx:{fontSize:18}})})),t(u,e({sx:{fontSize:14,fontWeight:600,color:"#111827"}},{children:R}))]})),o(a,e({sx:{display:"flex",alignItems:"center",gap:1}},{children:[t(f,e({variant:"contained",size:"small",disabled:!b||y||w,onClick:S,sx:{textTransform:"none",fontSize:"0.78rem",fontWeight:600,bgcolor:"#5928ed",px:2,py:.6,"&:hover":{bgcolor:"#4c1d95"},"&.Mui-disabled":{bgcolor:"#5928ed",color:"#fff",opacity:.4}}},{children:y?"Saving...":w?"Saved ✓":"Save FPB"})),t(s,e({size:"small",sx:{color:"#6b7280"},onClick:z},{children:t(_,{sx:{fontSize:18}})}))]}))]})),o(a,e({sx:{display:"flex",flex:1,overflow:"hidden"}},{children:[t(H,{block:g,isExtracted:b,isSaved:w,showEditMode:E,onBlockUpdate:m,onTagSelect:function(e){X(""),setTimeout(function(){return X(e)},50)},onVariableSelect:function(e){ne(""),setTimeout(function(){return ne(e)},50)},categories:B,subCategories:F,selectedCategoryId:L,selectedSubCategoryId:D,onCategoryChange:M,onSubCategoryChange:T}),o(a,e({sx:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",p:2,gap:1.5}},{children:[o(a,e({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0}},{children:[o(c,e({direction:"row",alignItems:"center",gap:1},{children:[o(u,e({sx:{fontSize:13,fontWeight:600,color:"#374151"}},{children:[(null==g?void 0:g.title)||"—"," APBs"]})),o(c,e({direction:"row",alignItems:"center",gap:.5},{children:[t(s,e({size:"small",onClick:function(){return U(function(e){return Math.max(1,e-1)})},disabled:1===Z,sx:{color:"#6b7280",p:.4}},{children:t(I,{sx:{fontSize:16}})})),o(u,e({sx:{fontSize:12.5,color:"#6b7280"}},{children:[Z," of ",(null===(l=null==g?void 0:g.members)||void 0===l?void 0:l.length)||0]})),t(s,e({size:"small",onClick:function(){return U(function(e){var n;return Math.min((null===(n=null==g?void 0:g.members)||void 0===n?void 0:n.length)||0,e+1)})},disabled:Z===((null===(d=null==g?void 0:g.members)||void 0===d?void 0:d.length)||0),sx:{color:"#6b7280",p:.4}},{children:t(W,{sx:{fontSize:16}})}))]}))]})),t(c,e({direction:"row",alignItems:"center",gap:1.5},{children:P&&(b?o(c,e({direction:"row",alignItems:"center",gap:1},{children:[t(u,e({sx:{fontSize:12.5,color:"#6b7280"}},{children:"Show Segments"})),t(a,e({sx:{width:36,height:20,borderRadius:"10px",bgcolor:"#7c3aed",display:"flex",alignItems:"center",px:.3,cursor:"pointer"}},{children:t(a,{sx:{width:14,height:14,borderRadius:"50%",bgcolor:"#fff",ml:"auto"}})}))]})):o(a,e({onClick:v,sx:{display:"flex",alignItems:"center",gap:1,px:2,py:.85,borderRadius:1.5,bgcolor:"#7c3aed",cursor:x?"default":"pointer","&:hover":{bgcolor:"#6d28d9"},userSelect:"none",opacity:x?.7:1}},{children:[t(A,{sx:{fontSize:15,color:"#fff"}}),t(u,e({sx:{fontSize:13,fontWeight:600,color:"#fff"}},{children:x?"Extracting...":"Extract Segments"}))]})))}))]})),o(a,e({sx:{flex:1,minHeight:0,position:"relative"}},{children:[x&&t(a,e({sx:{position:"absolute",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0,0,0,0.6)",zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:1}},{children:t(u,e({sx:{color:"#fff",fontSize:14,fontWeight:600}},{children:"Extracting segments..."}))})),o(a,e({sx:{border:"1px solid #30363d",borderRadius:1,overflow:"hidden",height:"100%"}},{children:[o(a,e({sx:{px:2,py:1,borderBottom:"1px solid #30363d",display:"flex",alignItems:"center",gap:1,bgcolor:"#161b22",flexShrink:0}},{children:[t(a,{sx:{width:12,height:12,borderRadius:"50%",bgcolor:"#ff5f57"}}),t(a,{sx:{width:12,height:12,borderRadius:"50%",bgcolor:"#febc2e"}}),t(a,{sx:{width:12,height:12,borderRadius:"50%",bgcolor:"#28c840"}}),o(u,e({sx:{ml:1,fontSize:11,color:"#8b949e",fontFamily:"monospace"}},{children:[(null===(h=null===(p=null==g?void 0:g.members)||void 0===p?void 0:p[Z-1])||void 0===h?void 0:h.section_name)||"—",".xml"]})),t(a,{sx:{flex:1}}),t(N,{isDarkMode:q,onChange:J})]})),t(G,{content:oe,selectedTag:Q,highlightVariable:ee,isDarkMode:q,height:"100%",fontSize:14})]}))]}))]}))]}))]}))};export{Z as default};
1
+ import{__assign as e,__spreadArray as n}from"tslib";import{jsxs as o,jsx as t,Fragment as i}from"react/jsx-runtime";import{useState as r,useRef as l,useEffect as d}from"react";import{Box as a,Stack as c,IconButton as s,Typography as u,Button as f,Tooltip as p,Chip as h,TextField as g,Accordion as m,AccordionSummary as x,AccordionDetails as b,Select as v,MenuItem as y,Divider as w,Dialog as S}from"@mui/material";import z from"@mui/icons-material/ExpandMore";import C from"@mui/icons-material/EditOutlined";import _ from"@mui/icons-material/Close";import k from"@mui/icons-material/ArrowBack";import I from"@mui/icons-material/NavigateBefore";import W from"@mui/icons-material/NavigateNext";import R from"@mui/icons-material/InfoOutlined";import A from"@mui/icons-material/AutoFixHighOutlined";import B from"@mui/icons-material/Check";import F from"@mui/icons-material/Add";import L from"@mui/icons-material/DeleteOutline";import D from"@monaco-editor/react";import M from"@mui/icons-material/DarkMode";import T from"@mui/icons-material/LightMode";var V={base:"vs-dark",inherit:!0,rules:[{token:"tag",foreground:"714be3",fontStyle:"bold"},{token:"attribute.name",foreground:"87CEFA"},{token:"attribute.value",foreground:"98FB98"},{token:"variable",foreground:"00FFFF"},{token:"delimiter",foreground:"888888"},{token:"white",foreground:"AAAAAA"}],colors:{"editor.foreground":"#FFFFFF","editor.background":"#030202","editorLineNumber.foreground":"#858585","editorCursor.foreground":"#FFFFFF","editorIndentGuide.background":"#404040","editorIndentGuide.activeBackground":"#707070"}},E={base:"vs",inherit:!0,rules:[{token:"tag",foreground:"5928ED",fontStyle:"bold"},{token:"attribute.name",foreground:"AF00DB"},{token:"attribute.value",foreground:"008000"},{token:"variable",foreground:"B000B0"},{token:"delimiter",foreground:"808080"},{token:"white",foreground:"000000"}],colors:{"editor.foreground":"#000000","editor.background":"#FFFFFF","editorLineNumber.foreground":"#999999","editorCursor.foreground":"#000000","editorIndentGuide.background":"#CCCCCC","editorIndentGuide.activeBackground":"#999999"}},O=function(n){var i=n.description,c=r(!1),s=c[0],f=c[1],p=r(!1),h=p[0],g=p[1],m=l(null);return d(function(){var e=m.current;e&&g(e.scrollHeight>e.clientHeight+1)},[i,s]),o(a,e({sx:{mt:1.5,border:"1px solid #e5e7eb",borderRadius:2,bgcolor:"#fff",display:"flex",flexDirection:"column",px:1.25,py:1}},{children:[t(u,e({ref:m,component:"div",sx:e({fontSize:11,color:"#6b7280",lineHeight:1.5,overflowY:s?"auto":"hidden",maxHeight:s?"calc(1.6em * 5)":"calc(1.6em * 3)",whiteSpace:"normal",display:s?"block":"-webkit-box"},s?{}:{WebkitBoxOrient:"vertical",WebkitLineClamp:3})},{children:i})),h&&t(u,e({component:"span",onClick:function(){return f(function(e){return!e})},sx:{mt:.75,alignSelf:"flex-end",fontSize:10,color:"#7c3aed",cursor:"pointer",fontWeight:500}},{children:s?"View less":"View more"}))]}))},P=function(n){var i=n.value,l=n.onChange,d=n.onDelete,f=r(!1),p=f[0],h=f[1];return o(a,e({sx:{display:"flex",alignItems:"flex-start",gap:1,p:1,border:"1px solid #e5e7eb",borderRadius:"8px",bgcolor:"#fff"}},{children:[t(a,e({sx:{width:18,height:18,borderRadius:"4px",bgcolor:"#f1f5f9",display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,color:"#64748b",flexShrink:0,mt:.1}},{children:"a"})),p?t(g,{autoFocus:!0,value:i,onChange:function(e){return l(e.target.value)},onBlur:function(){return h(!1)},size:"small",fullWidth:!0,multiline:!0,sx:{"& .MuiOutlinedInput-input":{fontSize:12.5}}}):t(u,e({sx:{fontSize:12.5,color:"#374151",lineHeight:1.55,flex:1}},{children:i})),o(c,e({direction:"row",gap:.25,sx:{flexShrink:0}},{children:[t(s,e({size:"small",onClick:function(){return h(!0)},sx:{color:"#6b7280"}},{children:t(C,{sx:{fontSize:14}})})),t(s,e({size:"small",onClick:d,sx:{color:"#dc2626"}},{children:t(L,{sx:{fontSize:14}})}))]}))]}))},j=function(n){var o=n.isDarkMode,i=n.onChange;return t(a,e({onClick:function(){return i(!o)},sx:{width:52,height:24,borderRadius:"12px",bgcolor:o?"#5928ed":"#f0f0f0",border:"1px solid",borderColor:o?"#5928ed":"#d1d5db",display:"flex",alignItems:"center",px:.4,cursor:"pointer",transition:"all 0.2s",justifyContent:o?"flex-end":"flex-start"}},{children:t(a,e({sx:{width:18,height:18,borderRadius:"50%",bgcolor:o?"#1e1e2e":"#f59e0b",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s"}},{children:t(o?M:T,{sx:{fontSize:11,color:"#fff"}})}))}))},N=function(n){var r=n.content,c=n.selectedTag,s=n.highlightVariable,u=n.isDarkMode,f=n.height,p=void 0===f?250:f,h=n.fontSize,g=void 0===h?12:h,m=l(),x=l();return d(function(){if(c&&m.current&&x.current){var e=m.current,n=e.getModel();if(n){for(var o=n.getValue().split("\n"),t=-1,i=0;i<o.length;i++){var r=o[i].match(/<([^\s>\/]+(?:\s[^\s>\/]+)*)/);if(r&&r[1].trim().toLowerCase()===c.toLowerCase()){t=i+1;break}}if(t>0){var l=t,d="</".concat(c.toLowerCase(),">");for(i=t;i<o.length;i++)if(o[i].toLowerCase().includes(d)){l=i+1;break}e.setSelection(new x.current.Selection(t,1,t,1)),e.trigger(null,"editor.unfold",{}),e.revealLineInCenterIfOutsideViewport(t);var a=e.deltaDecorations([],[{range:new x.current.Range(t,1,l,o[l-1].length+1),options:{isWholeLine:!0,className:"promptemon-viewer-highlight",inlineClassName:"promptemon-viewer-highlight"}}]);setTimeout(function(){return e.deltaDecorations(a,[])},2e3)}}}},[c]),d(function(){if(s&&m.current&&x.current){var e=m.current,n=e.getModel();if(n){for(var o=n.getValue().split("\n"),t=[],i=0;i<o.length;i++)for(var r=o[i].indexOf(s);-1!==r;)t.push(new x.current.Range(i+1,r+1,i+1,r+s.length+1)),r=o[i].indexOf(s,r+1);if(0!==t.length){e.revealLineInCenterIfOutsideViewport(t[0].startLineNumber);var l=e.deltaDecorations([],t.map(function(e){return{range:e,options:{inlineClassName:"promptemon-viewer-variable-highlight"}}}));setTimeout(function(){return e.deltaDecorations(l,[])},2e3)}}}},[s]),d(function(){x.current&&x.current.editor.setTheme(u?"promptemonViewerDark":"promptemonViewerLight")},[u]),o(i,{children:[t("style",{children:"\n .promptemon-viewer-highlight { background-color: rgba(89, 40, 237, 0.15); }\n .promptemon-viewer-variable-highlight { background-color: rgba(0, 255, 255, 0.2); border-radius: 2px; }\n "}),o(a,e({sx:{width:"100%",height:p,display:"flex",flexDirection:"column"}},{children:[t(a,{sx:{width:"100%",height:20,bgcolor:u?"#030202":"#fff",borderTopLeftRadius:8,borderTopRightRadius:8}}),t(a,e({sx:{flex:1,minHeight:0,overflow:"hidden"}},{children:t(D,{onMount:function(e,n){m.current=e,x.current=n,n.editor.defineTheme("promptemonViewerDark",V),n.editor.defineTheme("promptemonViewerLight",E),n.editor.setTheme(u?"promptemonViewerDark":"promptemonViewerLight"),n.languages.register({id:"promptemonViewerLang"}),n.languages.setMonarchTokensProvider("promptemonViewerLang",{tokenizer:{root:[[/(<)([a-zA-Z0-9\-]+)(\s*)/,["delimiter","tag","white"],"@tagBody"],[/(<\/)([a-zA-Z0-9\-]+)(\s*)(>)/,["delimiter","tag","white","delimiter"]],[/{{[^}]+}}/,"variable"]],tagBody:[[/[a-zA-Z0-9\:\-]+(?=\=)/,"attribute.name"],[/=/,"delimiter"],[/(".*?"|'.*?')/,"attribute.value"],[/\s+/,"white"],[/(\/?>)/,{token:"delimiter",next:"@pop"}]]}}),n.languages.registerFoldingRangeProvider("promptemonViewerLang",{provideFoldingRanges:function(e){var n=e.getLinesContent(),o=[],t=[];return n.forEach(function(e,n){var i=n+1,r=e.match(/<([a-zA-Z0-9\-]+)(\s[^>]*)?>/),l=e.match(/<\/([a-zA-Z0-9\-]+)>/);if(r&&!e.includes("/>")&&t.push({tag:r[1],start:i}),l)for(var d=l[1],a=t.length-1;a>=0;a--)if(t[a].tag===d){o.push({start:t[a].start,end:i}),t.splice(a,1);break}}),o}})},beforeMount:function(e){e.editor.defineTheme("promptemonViewerDark",V),e.editor.defineTheme("promptemonViewerLight",E),e.editor.setTheme(u?"promptemonViewerDark":"promptemonViewerLight")},theme:u?"promptemonViewerDark":"promptemonViewerLight",value:r,language:"promptemonViewerLang",onChange:function(){},options:{fontSize:g,minimap:{enabled:!1},wordWrap:"on",lineNumbers:"on",readOnly:!0,domReadOnly:!0,scrollBeyondLastLine:!1,padding:{top:4,bottom:12},folding:!0,automaticLayout:!0,scrollbar:{vertical:"visible",horizontal:"visible",verticalScrollbarSize:8}}})})),t(a,{sx:{width:"100%",height:20,bgcolor:u?"#030202":"#fff",borderBottomLeftRadius:8,borderBottomRightRadius:8}})]}))]})},G=function(i){var l,d,k,I,W=i.block,A=i.isExtracted,D=i.isSaved,M=i.showEditMode,T=i.onBlockUpdate,V=i.onTagSelect,E=i.onVariableSelect,j=i.categories,N=i.subCategories,G=i.selectedCategoryId,H=i.selectedSubCategoryId,Z=i.onCategoryChange,U=i.onSubCategoryChange,Y=r(!0),q=Y[0],J=Y[1],K=r(!0),Q=K[0],X=K[1],$=r(!0),ee=$[0],ne=$[1],oe=r(!0),te=oe[0],ie=oe[1],re=r(!1),le=re[0],de=re[1],ae=r(!0),ce=ae[0],se=ae[1],ue=r(!0),fe=ue[0],pe=ue[1],he=r(!1),ge=he[0],me=he[1],xe=r(!1),be=xe[0],ve=xe[1],ye=r(!1),we=ye[0],Se=ye[1],ze=r((null==W?void 0:W.title)||""),Ce=ze[0],_e=ze[1],ke=r((null==W?void 0:W.short_description)||""),Ie=ke[0],We=ke[1],Re=r((null==W?void 0:W.members)||[]),Ae=Re[0],Be=Re[1],Fe=r(Array.isArray(null==W?void 0:W.when_to_apply)?W.when_to_apply:(null==W?void 0:W.when_to_apply)?[W.when_to_apply]:[]),Le=Fe[0],De=Fe[1],Me=r(Array.isArray(null==W?void 0:W.when_not_to_apply)?W.when_not_to_apply:(null==W?void 0:W.when_not_to_apply)?[W.when_not_to_apply]:[]),Te=Me[0],Ve=Me[1],Ee=r(!1),Oe=Ee[0],Pe=Ee[1],je=r(""),Ne=je[0],Ge=je[1],He=r(""),Ze=He[0],Ue=He[1],Ye={boxShadow:"none",border:"1px solid #e5e7eb",borderRadius:"8px !important",mb:1.5,"&:before":{display:"none"},"&.Mui-expanded":{margin:"0 0 12px 0"}},qe={minHeight:44,px:2,borderRadius:2,"&.Mui-expanded":{minHeight:44},"& .MuiAccordionSummary-content":{my:"10px"}};return o(a,e({sx:{width:820,flexShrink:0,display:"flex",flexDirection:"column",overflow:"hidden",borderRight:"1px solid #e5e7eb"}},{children:[o(a,e({sx:{px:2.5,py:2,borderBottom:"1px solid #e5e7eb"}},{children:[o(c,e({direction:"row",alignItems:"center",justifyContent:"space-between"},{children:[o(c,e({direction:"row",alignItems:"center",gap:1,sx:{flex:1,minWidth:0}},{children:[t(p,e({title:"Functional Prompt Block",placement:"top"},{children:t(h,{label:"FPB",size:"small",sx:{bgcolor:"#f1f5f9",color:"#475569",fontWeight:700,fontSize:11,height:22,borderRadius:1}})})),we?t(g,{value:Ce,onChange:function(e){return _e(e.target.value)},size:"small",fullWidth:!0,sx:{"& .MuiOutlinedInput-input":{fontSize:15,fontWeight:700,py:.5}}}):t(u,e({sx:{fontWeight:700,fontSize:15,color:"#111827"}},{children:(null==W?void 0:W.title)||"—"}))]})),we?o(c,e({direction:"row",gap:.5},{children:[t(s,e({size:"small",sx:{color:"#6b7280"},onClick:function(){return Se(!1)}},{children:t(_,{sx:{fontSize:16}})})),t(s,e({size:"small",sx:{color:"#16a34a"},onClick:function(){T(e(e({},W),{title:Ce,short_description:Ie,members:Ae,when_to_apply:Le,when_not_to_apply:Te})),Se(!1)}},{children:t(B,{sx:{fontSize:16}})}))]})):!D&&M&&t(s,e({size:"small",sx:{color:"#6b7280"},onClick:function(){_e((null==W?void 0:W.title)||""),We((null==W?void 0:W.short_description)||""),Be((null==W?void 0:W.members)||[]),De(Array.isArray(null==W?void 0:W.when_to_apply)?W.when_to_apply:(null==W?void 0:W.when_to_apply)?[W.when_to_apply]:[]),Ve(Array.isArray(null==W?void 0:W.when_not_to_apply)?W.when_not_to_apply:(null==W?void 0:W.when_not_to_apply)?[W.when_not_to_apply]:[]),Se(!0)}},{children:t(C,{sx:{fontSize:16}})}))]})),we&&t(u,e({sx:{fontSize:11,color:"#5928ed",mt:.5}},{children:"Editing — changes won't be saved until you confirm"})),we?t(g,{value:Ie,onChange:function(e){return We(e.target.value)},size:"small",fullWidth:!0,multiline:!0,minRows:3,sx:{mt:1.5,"& .MuiOutlinedInput-input":{fontSize:12}}}):t(O,{description:(null==W?void 0:W.short_description)||"—"}),o(a,e({sx:{mt:1.5,border:"0.5px solid #d1d5db",borderRadius:"8px",display:"flex",overflow:"hidden"}},{children:[t(a,e({sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",borderRight:"1px solid #d1d5db",p:.5}},{children:o(c,e({direction:"row",alignItems:"center",gap:1},{children:[t(u,e({sx:{fontSize:10,color:"#87898d"}},{children:"Total APBs :"})),t(u,e({sx:{fontSize:10,fontWeight:700,color:"#5f5f5f"}},{children:(null===(l=null==W?void 0:W.members)||void 0===l?void 0:l.length)||0}))]}))})),t(a,e({sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",p:.5}},{children:o(c,e({direction:"row",alignItems:"center",gap:1},{children:[t(u,e({sx:{fontSize:10,color:"#87898d"}},{children:"Total Lines :"})),t(u,e({sx:{fontSize:10,fontWeight:700,color:"#5f5f5f"}},{children:(null===(d=null==W?void 0:W.members)||void 0===d?void 0:d.reduce(function(e,n){var o,t;return e+((null!==(o=n.end_line)&&void 0!==o?o:0)-(null!==(t=n.start_line)&&void 0!==t?t:0)+1)},0))||0}))]}))}))]}))]})),o(a,e({sx:{flex:1,overflow:"auto",px:2,py:2,"&::-webkit-scrollbar":{width:4},"&::-webkit-scrollbar-thumb":{bgcolor:"#e5e7eb",borderRadius:2}}},{children:[o(m,e({expanded:q,onChange:function(){return J(function(e){return!e})},sx:Ye,disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:18}}),sx:qe},{children:t(u,e({sx:{fontSize:13,fontWeight:600,color:"#374151"}},{children:"Categories"}))})),t(b,e({sx:{pt:0,px:2,pb:2}},{children:o(c,e({gap:1.5},{children:[o(a,{children:[t(u,e({sx:{fontSize:12,color:"#6b7280",mb:.5}},{children:"Category"})),we?t(v,e({fullWidth:!0,size:"small",value:G,onChange:function(e){Z(e.target.value),U("")},sx:{fontSize:13,borderRadius:1.5,"& fieldset":{borderColor:"#e5e7eb"}}},{children:j.map(function(n){return t(y,e({value:n.category_id},{children:n.category_name}),n.category_id)})})):t(g,{fullWidth:!0,size:"small",value:(null===(k=j.find(function(e){return e.category_id===G}))||void 0===k?void 0:k.category_name)||"—",InputProps:{readOnly:!0},sx:{"& .MuiOutlinedInput-root":{fontSize:13,borderRadius:1.5,"& fieldset":{borderColor:"#e5e7eb"}}}})]}),o(a,{children:[t(u,e({sx:{fontSize:12,color:"#6b7280",mb:.5}},{children:"Sub-Category"})),we?t(v,e({fullWidth:!0,size:"small",value:H,onChange:function(e){return U(e.target.value)},disabled:!G,sx:{fontSize:13,borderRadius:1.5,"& fieldset":{borderColor:"#e5e7eb"}}},{children:N.filter(function(e){return e.category_id===G}).map(function(n){return t(y,e({value:n.sub_category_id},{children:n.sub_category_name}),n.sub_category_id)})})):t(g,{fullWidth:!0,size:"small",value:(null===(I=N.find(function(e){return e.sub_category_id===H}))||void 0===I?void 0:I.sub_category_name)||"—",InputProps:{readOnly:!0},sx:{"& .MuiOutlinedInput-root":{fontSize:13,borderRadius:1.5,"& fieldset":{borderColor:"#e5e7eb"}}}})]})]}))}))]})),o(m,e({expanded:Q,onChange:function(){return X(function(e){return!e})},sx:Ye,disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:18}}),sx:qe},{children:t(u,e({sx:{fontSize:13,fontWeight:600,color:"#374151"}},{children:"Atomic Prompt Blocks (APBs)"}))})),o(b,e({sx:{pt:0,px:1,pb:2}},{children:[t(c,e({gap:1},{children:(we?Ae:(null==W?void 0:W.members)||[]).map(function(n,i){return o(a,e({sx:{px:2,py:1,borderRadius:2,bgcolor:"#fff"}},{children:[o(a,e({sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",mb:1,gap:1}},{children:[o(u,e({sx:{fontSize:14,fontWeight:500,color:"#111827"}},{children:[i+1,". ",n.section_name]})),we?t(s,e({size:"small",onClick:function(){return Be(function(e){return e.filter(function(e,n){return n!==i})})},sx:{color:"#dc2626",flexShrink:0}},{children:t(L,{sx:{fontSize:16}})})):t(a,e({onClick:function(){return V(n.section_name.split("_").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}).join("_"))},sx:{fontSize:14,color:"#475569",cursor:"pointer",flexShrink:0}},{children:"↗"}))]})),t(u,e({sx:{fontSize:12,lineHeight:1.5,color:"#64748b"}},{children:n.reason_for_inclusion})),A&&(r=n.segments||[],0===r.length?null:t(a,e({sx:{mt:1}},{children:t(a,e({sx:{display:"flex",flexWrap:"wrap",gap:1}},{children:r.map(function(e,n){return t(h,{clickable:!0,onClick:function(){return E(e.segmentized_text)},label:e.segmentized_text,sx:{borderRadius:1,bgcolor:"#eff6ff",color:"#3b82f6",border:"1px dashed #bfdbfe"}},n)})}))}))),t(w,{sx:{mt:2}})]}),i);var r})})),we&&o(a,e({onClick:function(){Ge(""),Ue(""),Pe(!0)},sx:{mt:1,display:"flex",alignItems:"center",justifyContent:"center",gap:.5,py:1,border:"1px dashed #d1d5db",borderRadius:1.5,cursor:"pointer",color:"#5928ed",fontSize:13,fontWeight:600,"&:hover":{bgcolor:"#f5f0ff"}}},{children:[t(F,{sx:{fontSize:16}})," Add APB"]}))]}))]})),o(m,e({expanded:ee,onChange:function(){return ne(function(e){return!e})},sx:Ye,disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:18}}),sx:qe},{children:o(u,e({sx:{fontSize:14,fontWeight:600,color:"#374151",display:"flex",alignItems:"center",flexDirection:"row"}},{children:["Applicability ",t("span",e({style:{color:"#94a3b8",fontWeight:400,fontSize:10,marginLeft:"12px"}},{children:"• When to apply / When not to apply"}))]}))})),o(b,e({sx:{pt:0,px:1.5,pb:1.5}},{children:[o(m,e({expanded:te,onChange:function(){return ie(function(e){return!e})},sx:{boxShadow:"none",border:"1px solid #e5e7eb",borderRadius:"6px !important",mb:1,"&:before":{display:"none"},"&.Mui-expanded":{margin:"0 0 8px 0"}},disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:16}}),sx:e(e({},qe),{bgcolor:"#f9fafb",borderRadius:"6px"})},{children:t(u,e({sx:{fontSize:12.5,fontWeight:500,color:"#374151"}},{children:"When to Apply this FPB"}))})),t(b,e({sx:{pt:.5,px:2,pb:1.5}},{children:o(c,e({gap:.75},{children:[(we?Le:Array.isArray(null==W?void 0:W.when_to_apply)?W.when_to_apply:(null==W?void 0:W.when_to_apply)?[W.when_to_apply]:["— Not yet available"]).map(function(n,i){return we?t(P,{value:n,onChange:function(e){return De(function(n){return n.map(function(n,o){return o===i?e:n})})},onDelete:function(){return De(function(e){return e.filter(function(e,n){return n!==i})})}},i):o(c,e({direction:"row",gap:1,alignItems:"flex-start"},{children:[o(u,e({sx:{fontSize:12,color:"#374151",fontWeight:700,mt:.1}},{children:[i+1,"."]})),t(u,e({sx:{fontSize:12.5,color:"#374151",lineHeight:1.55}},{children:n}))]}),i)}),we&&o(a,e({onClick:function(){return De(function(e){return n(n([],e,!0),[""],!1)})},sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:.5,py:.75,border:"1px dashed #d1d5db",borderRadius:1.5,cursor:"pointer",color:"#5928ed",fontSize:12.5,fontWeight:600,"&:hover":{bgcolor:"#f5f0ff"}}},{children:[t(F,{sx:{fontSize:15}})," Add When to Apply"]}))]}))}))]})),o(m,e({expanded:le,onChange:function(){return de(function(e){return!e})},sx:{boxShadow:"none",border:"1px solid #e5e7eb",borderRadius:"6px !important","&:before":{display:"none"}},disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:16}}),sx:e(e({},qe),{bgcolor:"#f9fafb",borderRadius:"6px"})},{children:t(u,e({sx:{fontSize:12.5,fontWeight:500,color:"#374151"}},{children:"When NOT to Apply this FPB"}))})),t(b,e({sx:{pt:.5,px:2,pb:1.5}},{children:we?o(c,e({gap:.75},{children:[Te.map(function(e,n){return t(P,{value:e,onChange:function(e){return Ve(function(o){return o.map(function(o,t){return t===n?e:o})})},onDelete:function(){return Ve(function(e){return e.filter(function(e,o){return o!==n})})}},n)}),o(a,e({onClick:function(){return Ve(function(e){return n(n([],e,!0),[""],!1)})},sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:.5,py:.75,border:"1px dashed #d1d5db",borderRadius:1.5,cursor:"pointer",color:"#5928ed",fontSize:12.5,fontWeight:600,"&:hover":{bgcolor:"#f5f0ff"}}},{children:[t(F,{sx:{fontSize:15}})," Add When NOT to Apply"]}))]})):Array.isArray(null==W?void 0:W.when_not_to_apply)||(null==W?void 0:W.when_not_to_apply)?t(c,e({gap:.75},{children:(Array.isArray(null==W?void 0:W.when_not_to_apply)?W.when_not_to_apply:[W.when_not_to_apply]).map(function(n,i){return o(c,e({direction:"row",gap:1,alignItems:"flex-start"},{children:[o(u,e({sx:{fontSize:12,color:"#374151",fontWeight:700,mt:.1}},{children:[i+1,"."]})),t(u,e({sx:{fontSize:12.5,color:"#374151",lineHeight:1.55}},{children:n}))]}),i)})})):t(u,e({sx:{fontSize:12.5,color:"#9ca3af",fontStyle:"italic"}},{children:"No conditions defined yet."}))}))]}))]}))]})),o(m,e({expanded:ce,onChange:function(){return se(function(e){return!e})},sx:Ye,disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:18}}),sx:qe},{children:o(u,e({sx:{fontSize:14,fontWeight:600,color:"#374151",display:"flex",alignItems:"center",flexDirection:"row"}},{children:["Specifications ",t("span",e({style:{color:"#94a3b8",fontWeight:400,fontSize:10,marginLeft:"12px"}},{children:"• Strict Rules / Input / Output"}))]}))})),t(b,e({sx:{pt:0,px:1.5,pb:1.5}},{children:[{label:"Guidelines",expanded:fe,setExpanded:pe,content:null==W?void 0:W.additional_guidelines},{label:"Input",expanded:ge,setExpanded:me,content:null},{label:"Output",expanded:be,setExpanded:ve,content:null}].map(function(n,i){var r=n.label,l=n.expanded,d=n.setExpanded,a=n.content;return o(m,e({expanded:l,onChange:function(){return d(function(e){return!e})},sx:{boxShadow:"none",border:"1px solid #e5e7eb",borderRadius:"6px !important",mb:i<2?1:0,"&:before":{display:"none"},"&.Mui-expanded":{margin:i<2?"0 0 8px 0":0}},disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:16}}),sx:e(e({},qe),{bgcolor:"#f9fafb",borderRadius:"6px"})},{children:o(c,e({direction:"row",alignItems:"center",gap:.5},{children:[t(u,e({sx:{fontSize:12.5,fontWeight:500,color:"#374151"}},{children:r})),"Guidelines"!==r&&t(R,{sx:{fontSize:13,color:"#9ca3af"}})]}))})),t(b,e({sx:{pt:.5,px:2,pb:1.5}},{children:t(u,e({sx:{fontSize:12.5,color:a?"#374151":"#9ca3af",fontStyle:a?"normal":"italic"}},{children:a||"No ".concat(r.toLowerCase()," defined yet.")}))}))]}),r)})}))]}))]})),o(S,e({open:Oe,onClose:function(){return Pe(!1)},maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px"}}},{children:[o(a,e({sx:{px:3,py:2,display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid #e5e7eb"}},{children:[t(u,e({sx:{fontWeight:700,fontSize:"1rem",color:"#111827"}},{children:"Add new APB"})),t(s,e({size:"small",onClick:function(){return Pe(!1)}},{children:t(_,{sx:{fontSize:"1.1rem",color:"#6b7280"}})}))]})),o(a,e({sx:{px:3,py:2.5,display:"flex",flexDirection:"column",gap:2}},{children:[o(a,{children:[t(u,e({sx:{fontSize:13,fontWeight:600,color:"#374151",mb:.75}},{children:"Title"})),t(g,{fullWidth:!0,size:"small",placeholder:"Specify the title of APB",value:Ne,onChange:function(e){return Ge(e.target.value)}})]}),o(a,{children:[t(u,e({sx:{fontSize:13,fontWeight:600,color:"#374151",mb:.75}},{children:"Description"})),t(g,{fullWidth:!0,size:"small",multiline:!0,minRows:3,placeholder:"Describe the APB",value:Ze,onChange:function(e){return Ue(e.target.value)}})]})]})),o(a,e({sx:{px:3,py:2,display:"flex",justifyContent:"flex-end",gap:1,borderTop:"1px solid #e5e7eb"}},{children:[t(f,e({variant:"outlined",onClick:function(){return Pe(!1)},sx:{textTransform:"none",borderColor:"#d1d5db",color:"#374151"}},{children:"Cancel"})),t(f,e({variant:"contained",onClick:function(){Be(function(e){return n(n([],e,!0),[{section_name:Ne,reason_for_inclusion:Ze,content:""}],!1)}),Pe(!1)},sx:{textTransform:"none",bgcolor:"#5928ed","&:hover":{bgcolor:"#4c1d95"}}},{children:"Save"}))]}))]}))]}))},H=function(n){var i,l,d,p,h,g=n.block,m=n.onBlockUpdate,x=n.isExtracting,b=n.isExtracted,v=n.onExtractSegments,y=n.isSaving,w=n.isSaved,S=n.onSave,z=n.onBack,C=n.title,R=void 0===C?"FPB Promptemon":C,B=n.categories,F=n.subCategories,L=n.selectedCategoryId,D=n.selectedSubCategoryId,M=n.onCategoryChange,T=n.onSubCategoryChange,V=n.showEditMode,E=void 0===V||V,O=n.showExtractSegments,P=void 0===O||O,H=r(1),Z=H[0],U=H[1],Y=r(!0),q=Y[0],J=Y[1],K=r(""),Q=K[0],X=K[1],$=r(""),ee=$[0],ne=$[1],oe=(null===(i=null==g?void 0:g.members)||void 0===i?void 0:i.map(function(e){if(!b||!e.segments||0===e.segments.length)return e.content||"";var n=e.content||"";return e.segments.forEach(function(e){e.raw_text&&e.segmentized_text&&(n=n.split(e.raw_text).join(e.segmentized_text))}),n}).join("\n\n"))||"";return o(a,e({sx:{width:"100%",height:"100%",display:"flex",flexDirection:"column",bgcolor:"#fff",overflow:"hidden"}},{children:[o(a,e({sx:{px:2.5,py:1.5,borderBottom:"1px solid #e5e7eb",display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#fff",flexShrink:0}},{children:[o(c,e({direction:"row",alignItems:"center",gap:1},{children:[t(s,e({size:"small",sx:{color:"#6b7280"},onClick:z},{children:t(k,{sx:{fontSize:18}})})),t(u,e({sx:{fontSize:14,fontWeight:600,color:"#111827"}},{children:R}))]})),o(a,e({sx:{display:"flex",alignItems:"center",gap:1}},{children:[t(f,e({variant:"contained",size:"small",disabled:!b||y||w,onClick:S,sx:{textTransform:"none",fontSize:"0.78rem",fontWeight:600,bgcolor:"#5928ed",px:2,py:.6,"&:hover":{bgcolor:"#4c1d95"},"&.Mui-disabled":{bgcolor:"#5928ed",color:"#fff",opacity:.4}}},{children:y?"Saving...":w?"Saved ✓":"Save FPB"})),t(s,e({size:"small",sx:{color:"#6b7280"},onClick:z},{children:t(_,{sx:{fontSize:18}})}))]}))]})),o(a,e({sx:{display:"flex",flex:1,overflow:"hidden"}},{children:[t(G,{block:g,isExtracted:b,isSaved:w,showEditMode:E,onBlockUpdate:m,onTagSelect:function(e){X(""),setTimeout(function(){return X(e)},50)},onVariableSelect:function(e){ne(""),setTimeout(function(){return ne(e)},50)},categories:B,subCategories:F,selectedCategoryId:L,selectedSubCategoryId:D,onCategoryChange:M,onSubCategoryChange:T}),o(a,e({sx:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",p:2,gap:1.5}},{children:[o(a,e({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0}},{children:[o(c,e({direction:"row",alignItems:"center",gap:1},{children:[o(u,e({sx:{fontSize:13,fontWeight:600,color:"#374151"}},{children:[(null==g?void 0:g.title)||"—"," APBs"]})),o(c,e({direction:"row",alignItems:"center",gap:.5},{children:[t(s,e({size:"small",onClick:function(){return U(function(e){return Math.max(1,e-1)})},disabled:1===Z,sx:{color:"#6b7280",p:.4}},{children:t(I,{sx:{fontSize:16}})})),o(u,e({sx:{fontSize:12.5,color:"#6b7280"}},{children:[Z," of ",(null===(l=null==g?void 0:g.members)||void 0===l?void 0:l.length)||0]})),t(s,e({size:"small",onClick:function(){return U(function(e){var n;return Math.min((null===(n=null==g?void 0:g.members)||void 0===n?void 0:n.length)||0,e+1)})},disabled:Z===((null===(d=null==g?void 0:g.members)||void 0===d?void 0:d.length)||0),sx:{color:"#6b7280",p:.4}},{children:t(W,{sx:{fontSize:16}})}))]}))]})),t(c,e({direction:"row",alignItems:"center",gap:1.5},{children:P&&(b?o(c,e({direction:"row",alignItems:"center",gap:1},{children:[t(u,e({sx:{fontSize:12.5,color:"#6b7280"}},{children:"Show Segments"})),t(a,e({sx:{width:36,height:20,borderRadius:"10px",bgcolor:"#7c3aed",display:"flex",alignItems:"center",px:.3,cursor:"pointer"}},{children:t(a,{sx:{width:14,height:14,borderRadius:"50%",bgcolor:"#fff",ml:"auto"}})}))]})):o(a,e({onClick:v,sx:{display:"flex",alignItems:"center",gap:1,px:2,py:.85,borderRadius:1.5,bgcolor:"#7c3aed",cursor:x?"default":"pointer","&:hover":{bgcolor:"#6d28d9"},userSelect:"none",opacity:x?.7:1}},{children:[t(A,{sx:{fontSize:15,color:"#fff"}}),t(u,e({sx:{fontSize:13,fontWeight:600,color:"#fff"}},{children:x?"Extracting...":"Extract Segments"}))]})))}))]})),o(a,e({sx:{flex:1,minHeight:0,position:"relative"}},{children:[x&&t(a,e({sx:{position:"absolute",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0,0,0,0.6)",zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:1}},{children:t(u,e({sx:{color:"#fff",fontSize:14,fontWeight:600}},{children:"Extracting segments..."}))})),o(a,e({sx:{border:"1px solid #30363d",borderRadius:1,overflow:"hidden",height:"100%"}},{children:[o(a,e({sx:{px:2,py:1,borderBottom:"1px solid #30363d",display:"flex",alignItems:"center",gap:1,bgcolor:"#161b22",flexShrink:0}},{children:[t(a,{sx:{width:12,height:12,borderRadius:"50%",bgcolor:"#ff5f57"}}),t(a,{sx:{width:12,height:12,borderRadius:"50%",bgcolor:"#febc2e"}}),t(a,{sx:{width:12,height:12,borderRadius:"50%",bgcolor:"#28c840"}}),o(u,e({sx:{ml:1,fontSize:11,color:"#8b949e",fontFamily:"monospace"}},{children:[(null===(h=null===(p=null==g?void 0:g.members)||void 0===p?void 0:p[Z-1])||void 0===h?void 0:h.section_name)||"—",".xml"]})),t(a,{sx:{flex:1}}),t(j,{isDarkMode:q,onChange:J})]})),t(N,{content:oe,selectedTag:Q,highlightVariable:ee,isDarkMode:q,height:"100%",fontSize:14})]}))]}))]}))]}))]}))};export{H as default};
2
2
  //# sourceMappingURL=PromptemonViewer.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e}from"tslib";import{jsxs as n,jsx as i}from"react/jsx-runtime";import{useState as o,useMemo as t}from"react";import{Box as r}from"@mui/system";import{Typography as l,Chip as a,IconButton as c,Accordion as d,AccordionSummary as s,AccordionDetails as h,Divider as f}from"@mui/material";import m from"@mui/icons-material/Close";import u from"@mui/icons-material/ExpandMore";import{LightbulbOutlined as g,ManageSearchOutlined as p,ChatBubbleOutlineOutlined as x}from"@mui/icons-material";import v from"@mui/icons-material/AutoAwesome";import b from"../ChatCitation/ChatCitationRenderer.js";var y=function(e){var n=document.createElement("div");return n.innerHTML=e,Array.from(n.querySelectorAll("li")).map(function(e){return e.innerHTML})},_=function(){return i(r,e({component:"svg",viewBox:"0 0 24 24",sx:{width:14,height:14,fill:"#5928ed"}},{children:i("path",{d:"M12 2a7 7 0 0 0-4 12.74V17a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2v-2.26A7 7 0 0 0 12 2zm-1 19h2v1h-2v-1z"})}))},k=function(k){var S,C=k.open,z=k.onClose,w=k.data,I=o(null),A=I[0],R=I[1],B=t(function(){var e;return A&&w&&null!==(e=w.block_cognitive_citations.find(function(e){return String(e.citation_number)===A}))&&void 0!==e?e:null},[A,w]),W=t(function(){return(null==w?void 0:w.block_cognitive_reasoning_html)?y(w.block_cognitive_reasoning_html):[]},[null==w?void 0:w.block_cognitive_reasoning_html]),D=t(function(){return(null==w?void 0:w.block_cognitive_gap_html)?y(w.block_cognitive_gap_html):[]},[null==w?void 0:w.block_cognitive_gap_html]),M=function(o,t){for(var l,a,c=[],d=/<a[^>]*href="([^"]+)"[^>]*>(.*?)<\/a>/g,s=0,h=0,f=function(){var f=a[1].replace(/^.*\$/,""),m=a[2],u=A===f;a.index>s&&c.push(i("span",{children:o.substring(s,a.index)},"txt-".concat(t,"-").concat(h++))),c.push(n("span",{children:[n("span",e({onClick:function(){return R(function(e){return e===f?null:f})},style:{color:"#2563EB",fontWeight:500,cursor:"pointer",textDecoration:"underline"}},{children:[m,i(x,{sx:{fontSize:"12px",ml:.2}})]})),u&&B&&i(r,e({sx:{maxHeight:"35vh",padding:"6px",overflow:"auto",backgroundColor:"#ffffff",mt:1}},{children:i(b,{showRootContainer:!1,rootContainer:{relevanceScore:null!==(l=null==w?void 0:w.block_cognitive_confidence)&&void 0!==l?l:0,slotStyles:{container:{border:"",paddingLeft:"-20px",color:"black"}}},ruleBookContainer:{title:B.title||B.section_ref||"Rule Book",data:{content:B.content||B.paraphrase||"",highlighted_texts:Array.isArray(B.highlight)?B.highlight:B.highlight?[B.highlight]:[]},slotStyles:{outerContainer:{margin:"0",color:"black",minHeight:"350px"}}},additionalData:{RuleBookDetailedViewVerticallyStacked:!0},reversePanels:!0})}))]},"anchor-".concat(t,"-").concat(f))),s=d.lastIndex};null!==(a=d.exec(o));)f();return s<o.length&&c.push(i("span",{children:o.substring(s)},"txt-end-".concat(t,"-").concat(h++))),c};return C?n(r,e({sx:{width:"min(500px, calc(100vw - 16px))",maxWidth:"calc(100vw - 16px)",maxHeight:"80vh",borderRadius:3,display:"flex",flexDirection:"column",overflow:"hidden",border:"1px solid #e0e0e0",backgroundColor:"#fff"}},{children:[n(r,e({sx:{px:2,py:1,borderBottom:"1px solid #e0e0e0",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,backgroundColor:"#e9ecfd"}},{children:[n(r,e({display:"flex",alignItems:"center",gap:1},{children:[i(_,{}),i(l,e({fontWeight:500,sx:{fontSize:"0.72rem"}},{children:"Cognitive Decisioning AI"}))]})),n(r,e({display:"flex",alignItems:"center",gap:1},{children:[i(a,{icon:i(v,{sx:{fontSize:12}}),label:"AI Relevance: ".concat(null!==(S=null==w?void 0:w.block_cognitive_confidence)&&void 0!==S?S:0,"%"),size:"small",sx:{fontWeight:500,fontSize:"0.68rem",backgroundColor:"#ffffff",color:"#000000",border:"1px solid #ac93f6",height:20,"& .MuiChip-label":{fontSize:"0.68rem",px:.75}}}),i(c,e({size:"small",onClick:z},{children:i(m,{fontSize:"small"})}))]}))]})),n(r,e({sx:{flex:1,overflowY:"auto",p:.5}},{children:[n(d,e({defaultExpanded:!0,disableGutters:!0,elevation:0},{children:[i(s,e({expandIcon:i(u,{})},{children:n(l,e({sx:{display:"flex",alignItems:"center",gap:.8,fontSize:"0.78rem"},fontWeight:600},{children:[i(r,e({sx:{width:24,height:24,borderRadius:"50%",backgroundColor:"#e9ecfd",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0}},{children:i(g,{sx:{fontSize:14,color:"#5928ed"}})})),"Decision Making Factors"]}))})),i(h,{children:i(r,e({sx:{padding:0,margin:0}},{children:W.length>0?W.map(function(o,t){return n(r,e({sx:{marginBottom:"6px",display:"flex",gap:1}},{children:[n(l,e({variant:"body2",sx:{fontWeight:500,fontSize:"0.75rem"}},{children:[t+1,"."]})),i(r,e({sx:{flex:1}},{children:i(l,e({variant:"body2",component:"span",sx:{fontSize:"0.75rem"}},{children:M(o,t)}))}))]}),t)}):i(l,e({variant:"body2",color:"gray",sx:{mb:.5,pl:3,fontSize:"0.72rem"}},{children:"No Reasons Found"}))}))})]})),i(f,{}),n(d,e({disableGutters:!0,elevation:0},{children:[i(s,e({expandIcon:i(u,{})},{children:n(l,e({sx:{display:"flex",alignItems:"center",gap:.8,fontSize:"0.78rem"},fontWeight:600},{children:[i(r,e({sx:{width:24,height:24,borderRadius:"50%",backgroundColor:"#e9ecfd",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0}},{children:i(p,{sx:{fontSize:14,color:"#5928ed"}})})),"Gaps in Decision"]}))})),i(h,{children:i(r,e({sx:{padding:0,margin:0}},{children:D.length>0?D.map(function(o,t){return n(r,e({sx:{marginBottom:"6px",display:"flex",gap:1}},{children:[n(l,e({variant:"body2",sx:{fontWeight:500,fontSize:"0.75rem"}},{children:[t+1,"."]})),i(l,{variant:"body2",component:"span",sx:{fontSize:"0.75rem"},dangerouslySetInnerHTML:{__html:o}})]}),t)}):i(l,e({variant:"body2",color:"gray",sx:{mb:.5,pl:3,fontSize:"0.72rem"}},{children:"No Gaps Found"}))}))})]}))]}))]})):null};export{k as default};
1
+ import{__assign as n}from"tslib";import{jsxs as i,jsx as e}from"react/jsx-runtime";import{useState as o,useMemo as t}from"react";import{Box as l}from"@mui/system";import{Typography as r,Chip as a,IconButton as c,Accordion as d,AccordionSummary as s,AccordionDetails as u,Divider as h}from"@mui/material";import f from"@mui/icons-material/Close";import m from"@mui/icons-material/ExpandMore";import{LightbulbOutlined as v,ManageSearchOutlined as x,ChatBubbleOutlineOutlined as p}from"@mui/icons-material";import g from"@mui/icons-material/AutoAwesome";import b from"../ChatCitation/ChatCitationRenderer.js";var y=function(n){var i=document.createElement("div");return i.innerHTML=n,Array.from(i.querySelectorAll("li")).map(function(n){return n.innerHTML})},C=function(i){var o=i.style;return e(l,n({component:"svg",viewBox:"0 0 24 24",sx:n({width:14,height:14,fill:"#5928ed"},o)},{children:e("path",{d:"M12 2a7 7 0 0 0-4 12.74V17a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2v-2.26A7 7 0 0 0 12 2zm-1 19h2v1h-2v-1z"})}))},_=function(_){var S,k=_.open,z=_.onClose,I=_.data,w=_.styles,A=o(null),B=A[0],R=A[1],D=t(function(){var n;return B&&I&&null!==(n=I.block_cognitive_citations.find(function(n){return String(n.citation_number)===B}))&&void 0!==n?n:null},[B,I]),T=t(function(){return(null==I?void 0:I.block_cognitive_reasoning_html)?y(I.block_cognitive_reasoning_html):[]},[null==I?void 0:I.block_cognitive_reasoning_html]),M=t(function(){return(null==I?void 0:I.block_cognitive_gap_html)?y(I.block_cognitive_gap_html):[]},[null==I?void 0:I.block_cognitive_gap_html]),W=function(o,t){for(var r,a,c,d,s,u,h,f=[],m=/<a[^>]*href="([^"]+)"[^>]*>(.*?)<\/a>/g,v=0,x=0,g=function(){var g=h[1].replace(/^.*\$/,""),y=h[2],C=B===g;h.index>v&&f.push(e("span",{children:o.substring(v,h.index)},"txt-".concat(t,"-").concat(x++))),f.push(i("span",{children:[i("span",n({onClick:function(){return R(function(n){return n===g?null:g})},style:n({color:"#2563EB",fontWeight:500,cursor:"pointer",textDecoration:"underline"},null==w?void 0:w.citationLink)},{children:[y,e(p,{sx:{fontSize:"12px",ml:.2}})]})),C&&D&&e(l,n({sx:n({maxHeight:"35vh",padding:"6px",overflow:"auto",backgroundColor:"#ffffff",mt:1},null==w?void 0:w.citationContainer)},{children:e(b,{showRootContainer:!1,modalContainerStyle:null==w?void 0:w.citationModalContainer,rootContainer:{relevanceScore:null!==(r=null==I?void 0:I.block_cognitive_confidence)&&void 0!==r?r:0,slotStyles:{container:n({border:"",paddingLeft:"-20px",color:null!==(c=null===(a=null==w?void 0:w.textContent)||void 0===a?void 0:a.color)&&void 0!==c?c:"black"},null==w?void 0:w.citationRootContainer)}},ruleBookContainer:{title:D.training_data_title||D.title||D.section_ref||"Rule Book",data:{content:(null===(d=D.data_sources)||void 0===d?void 0:d.join("\n\n"))||D.content||D.paraphrase||"",highlighted_texts:D.paraphrase?Array.isArray(D.paraphrase)?D.paraphrase:[D.paraphrase]:Array.isArray(D.highlight)?D.highlight:D.highlight?[D.highlight]:[]},slotStyles:{title:null==w?void 0:w.citationTitle,body:null==w?void 0:w.citationBody,dataContainer:null==w?void 0:w.citationDataContainer,outerContainer:n({margin:"0",color:null!==(u=null===(s=null==w?void 0:w.textContent)||void 0===s?void 0:s.color)&&void 0!==u?u:"black",minHeight:"350px"},null==w?void 0:w.citationRuleBookContainer)}},additionalData:{RuleBookDetailedViewVerticallyStacked:!0},reversePanels:!0})}))]},"anchor-".concat(t,"-").concat(g))),v=m.lastIndex};null!==(h=m.exec(o));)g();return v<o.length&&f.push(e("span",{children:o.substring(v)},"txt-end-".concat(t,"-").concat(x++))),f};return k?i(l,n({sx:n({width:"min(500px, calc(100vw - 16px))",maxWidth:"calc(100vw - 16px)",maxHeight:"80vh",borderRadius:3,display:"flex",flexDirection:"column",overflow:"hidden",border:"1px solid #e0e0e0",backgroundColor:"#fff",color:"#111827"},null==w?void 0:w.container)},{children:[i(l,n({sx:n({px:2,py:1,borderBottom:"1px solid #e0e0e0",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,backgroundColor:"#e9ecfd"},null==w?void 0:w.header)},{children:[i(l,n({display:"flex",alignItems:"center",gap:1},{children:[e(C,{style:null==w?void 0:w.headerIcon}),e(r,n({fontWeight:500,sx:n({fontSize:"0.72rem"},null==w?void 0:w.headerTitleText)},{children:"Cognitive Decisioning AI"}))]})),i(l,n({display:"flex",alignItems:"center",gap:1},{children:[e(a,{icon:e(g,{sx:{fontSize:12}}),label:"AI Relevance: ".concat(null!==(S=null==I?void 0:I.block_cognitive_confidence)&&void 0!==S?S:0,"%"),size:"small",sx:n({fontWeight:500,fontSize:"0.68rem",backgroundColor:"#ffffff",color:"#000000",border:"1px solid #ac93f6",height:20,"& .MuiChip-label":{fontSize:"0.68rem",px:.75}},null==w?void 0:w.badge)}),e(c,n({size:"small",onClick:z,sx:null==w?void 0:w.closeButton},{children:e(f,{fontSize:"small"})}))]}))]})),i(l,n({sx:n({flex:1,overflowY:"auto",p:.5},null==w?void 0:w.body)},{children:[i(d,n({defaultExpanded:!0,disableGutters:!0,elevation:0,sx:null==w?void 0:w.accordion},{children:[e(s,n({expandIcon:e(m,{}),sx:null==w?void 0:w.accordionSummary},{children:i(r,n({sx:n({display:"flex",alignItems:"center",gap:.8,fontSize:"0.78rem"},null==w?void 0:w.sectionTitle),fontWeight:600},{children:[e(l,n({sx:n({width:24,height:24,borderRadius:"50%",backgroundColor:"#e9ecfd",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},null==w?void 0:w.sectionIcon)},{children:e(v,{sx:{fontSize:14,color:"#5928ed"}})})),"Decision Making Factors"]}))})),e(u,n({sx:null==w?void 0:w.accordionDetails},{children:e(l,n({sx:{padding:0,margin:0}},{children:T.length>0?T.map(function(o,t){return i(l,n({sx:n({marginBottom:"6px",display:"flex",gap:1},null==w?void 0:w.sectionItem)},{children:[i(r,n({variant:"body2",sx:n({fontWeight:500,fontSize:"0.75rem"},null==w?void 0:w.indexText)},{children:[t+1,"."]})),e(l,n({sx:{flex:1}},{children:e(r,n({variant:"body2",component:"span",sx:n({fontSize:"0.75rem"},null==w?void 0:w.textContent)},{children:W(o,t)}))}))]}),t)}):e(r,n({variant:"body2",color:"gray",sx:n({mb:.5,pl:3,fontSize:"0.72rem"},null==w?void 0:w.sectionSubtitle)},{children:"No Reasons Found"}))}))}))]})),e(h,{}),i(d,n({disableGutters:!0,elevation:0,sx:null==w?void 0:w.accordion},{children:[e(s,n({expandIcon:e(m,{}),sx:null==w?void 0:w.accordionSummary},{children:i(r,n({sx:n({display:"flex",alignItems:"center",gap:.8,fontSize:"0.78rem"},null==w?void 0:w.sectionTitle),fontWeight:600},{children:[e(l,n({sx:n({width:24,height:24,borderRadius:"50%",backgroundColor:"#e9ecfd",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},null==w?void 0:w.sectionIcon)},{children:e(x,{sx:{fontSize:14,color:"#5928ed"}})})),"Gaps in Decision"]}))})),e(u,n({sx:null==w?void 0:w.accordionDetails},{children:e(l,n({sx:{padding:0,margin:0}},{children:M.length>0?M.map(function(o,t){return i(l,n({sx:n({marginBottom:"6px",display:"flex",gap:1},null==w?void 0:w.sectionItem)},{children:[i(r,n({variant:"body2",sx:n({fontWeight:500,fontSize:"0.75rem"},null==w?void 0:w.indexText)},{children:[t+1,"."]})),e(r,{variant:"body2",component:"span",sx:n({fontSize:"0.75rem"},null==w?void 0:w.textContent),dangerouslySetInnerHTML:{__html:o}})]}),t)}):e(r,n({variant:"body2",color:"gray",sx:n({mb:.5,pl:3,fontSize:"0.72rem"},null==w?void 0:w.sectionSubtitle)},{children:"No Gaps Found"}))}))}))]}))]}))]})):null};export{_ as default};
2
2
  //# sourceMappingURL=Cognitivereasoningpanel.js.map