@viswa-test/test-citation 0.0.232 → 0.0.233
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
- package/dist/cjs/features/RequirementAI/components/RichTextEditor/Editor/Editor.js +1 -1
- package/dist/cjs/features/RequirementAI/components/RichTextEditor/Editor/plugins/InitialHtml.js +1 -1
- package/dist/cjs/features/RequirementAI/components/RichTextEditor/Editor/plugins/ManualNode.js +1 -1
- package/dist/cjs/features/RequirementAI/components/RichTextEditor/Editor/plugins/UpdateNode.js +1 -1
- package/dist/cjs/features/RequirementAI/components/RichTextEditor/Editor/theme/theme.css.js +1 -1
- package/dist/cjs/features/RequirementAI/components/RichTextEditor/RichTextEditor.js +1 -1
- package/dist/cjs/features/RequirementAI/components/UserStoryCard/Popups/DeviationSummary.js +1 -1
- package/dist/cjs/features/RequirementAI/components/UserStoryCard/UserStoryCard.js +1 -1
- package/dist/cjs/features/RequirementAI/components/userstory-with-citation/UserStoryWithCitation.js +1 -1
- package/dist/cjs/features/RequirementAI/components/userstory-with-citation/components/InlineManualComponent.js +1 -1
- package/dist/cjs/features/RequirementAI/components/userstory-with-citation/components/InlineUpdatedComponent.js +1 -1
- package/dist/cjs/features/RequirementAI/utils/helpers.js +1 -1
- package/dist/cjs/utils/tagHelper.js +2 -0
- package/dist/cjs/utils/tagHelper.js.map +1 -0
- package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
- package/dist/features/RequirementAI/components/RichTextEditor/Editor/Editor.js +1 -1
- package/dist/features/RequirementAI/components/RichTextEditor/Editor/plugins/InitialHtml.js +1 -1
- package/dist/features/RequirementAI/components/RichTextEditor/Editor/plugins/ManualNode.js +1 -1
- package/dist/features/RequirementAI/components/RichTextEditor/Editor/plugins/UpdateNode.js +1 -1
- package/dist/features/RequirementAI/components/RichTextEditor/Editor/theme/theme.css.js +1 -1
- package/dist/features/RequirementAI/components/RichTextEditor/RichTextEditor.js +1 -1
- package/dist/features/RequirementAI/components/UserStoryCard/Popups/DeviationSummary.js +1 -1
- package/dist/features/RequirementAI/components/UserStoryCard/UserStoryCard.js +1 -1
- package/dist/features/RequirementAI/components/userstory-with-citation/UserStoryWithCitation.js +1 -1
- package/dist/features/RequirementAI/components/userstory-with-citation/components/InlineManualComponent.js +1 -1
- package/dist/features/RequirementAI/components/userstory-with-citation/components/InlineUpdatedComponent.js +1 -1
- package/dist/features/RequirementAI/utils/helpers.js +1 -1
- package/dist/types/src/CognitiveCompareTest.d.ts.map +1 -1
- package/dist/types/src/RedlineEditorTest.d.ts.map +1 -1
- package/dist/types/src/RequirementAiTest.d.ts.map +1 -1
- package/dist/types/src/constants/deviationData.d.ts +887 -0
- package/dist/types/src/constants/deviationData.d.ts.map +1 -0
- package/dist/types/src/constants/treeData.d.ts +732 -0
- package/dist/types/src/constants/treeData.d.ts.map +1 -0
- package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts +867 -1647
- package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/SubSectionAccordion.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/Editor.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/plugins/InitialHtml.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/plugins/ManualNode.d.ts +6 -2
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/plugins/ManualNode.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/plugins/UpdateNode.d.ts +6 -2
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/plugins/UpdateNode.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/RichTextEditor.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/UserStoryCard/Popups/BlockedPopup.d.ts +8 -0
- package/dist/types/src/features/RequirementAI/components/UserStoryCard/Popups/BlockedPopup.d.ts.map +1 -0
- package/dist/types/src/features/RequirementAI/components/UserStoryCard/Popups/DeviationSummary.d.ts +12 -6
- package/dist/types/src/features/RequirementAI/components/UserStoryCard/Popups/DeviationSummary.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/UserStoryCard/UserStoryCard.d.ts +1 -2
- package/dist/types/src/features/RequirementAI/components/UserStoryCard/UserStoryCard.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/userstory-with-citation/UserStoryWithCitation.d.ts +4 -0
- package/dist/types/src/features/RequirementAI/components/userstory-with-citation/UserStoryWithCitation.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/userstory-with-citation/components/InlineUpdatedComponent.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/types/aiReasoning.type.d.ts +1 -0
- package/dist/types/src/features/RequirementAI/types/aiReasoning.type.d.ts.map +1 -1
- package/dist/types/src/utils/tagHelper.d.ts +5 -0
- package/dist/types/src/utils/tagHelper.d.ts.map +1 -0
- package/dist/utils/tagHelper.js +2 -0
- package/dist/utils/tagHelper.js.map +1 -0
- package/package.json +1 -1
- package/dist/cjs/features/GptWebCitation/GptWebCitationMarkdown.js +0 -2
- package/dist/cjs/features/GptWebCitation/GptWebCitationMarkdown.js.map +0 -1
- package/dist/features/GptWebCitation/GptWebCitationMarkdown.js +0 -2
- package/dist/features/GptWebCitation/GptWebCitationMarkdown.js.map +0 -1
- package/dist/types/src/RedlineApprovalCardTest.d.ts +0 -1
- package/dist/types/src/RedlineApprovalCardTest.d.ts.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t,Fragment as l}from"react/jsx-runtime";import{useState as n,useRef as o,useEffect as i}from"react";import{ChevronUp as a,ChevronDown as r,ExternalLink as s,Download as d,Share2 as u,Copy as c,LoaderCircle as v,PencilIcon as p,Plus as m,Trash2 as y,X as h,Ellipsis as f,Hourglass as g,Check as S,ChevronUpIcon as C,ChevronDownIcon as I,Info as b,Bookmark as w}from"lucide-react";import N from"showdown";import{Tooltip as D,Menu as E,MenuItem as x}from"@mui/material";import B from"../../icons/Illustration.svg.js";import{v4 as T}from"uuid";import A from"./UserStoryCard.module.css.js";import{formatMarkdown as U,indentMarkdown as k}from"../../utils/helpers.js";import{replaceTitleSection as P}from"../../utils/user-story.utils.js";import R from"../../shared/AtomicButton.js";import _ from"../RichTextEditor/RichTextEditor.js";import F from"../userstory-with-citation/UserStoryWithCitation.js";import{SectionStatus as M,useRequirementAI as L}from"../RequirementAIWrapper/RequirementAIWrapper.js";import{BigEnoughPanel as j}from"../story-screen/BigEnoughPanel.js";import{InlineTitleEditor as V}from"./TitleEditor/TitleEditor.js";import{updateRedlineDocument as z,getRedlineDocumentId as O,createRedlineDocument as W}from"../../../../service/redlineService.js";import $ from"./ClinicalTrialSection.js";import{CompletionPanel as G}from"../story-screen/CompletionPanel.js";import H from"../../icons/CDIcon.js";const q={[M.WAITING]:"WAITING TO GENERATE",[M.IN_PROGRESS]:"IN PROGRESS",[M.GENERATED]:"GENERATED",[M.FAILED]:"FAILED",[M.GENERATE]:"GENERATE",[M.APPROVED]:"APPROVED"};function Q(e){const l=[],n=/<learned>(.*?)<\/learned>/g;let o,i=0,a=0;for(;null!==(o=n.exec(e));){const[,r]=o,s=o.index;s>i&&l.push(t("span",{children:e.slice(i,s)},"text-pre-"+a++)),l.push(t(D,{title:r,placement:"top",children:t(b,{size:16,className:"inline-block mx-1 text-blue-500 hover:text-blue-700 cursor"})},`tooltip-${T()}`)),i=n.lastIndex}return i<(null==e?void 0:e.length)&&l.push(t("span",{children:e.slice(i)},"text-post-"+a++)),l}function Z(e,t,l){var n;if(!e)return{};if(t)return{...e.parentConfig};const o={...e.childConfig};return l&&(null===(n=e.subFeatureOverrides)||void 0===n?void 0:n[l])?{...o,...e.subFeatureOverrides[l]}:o}const J=({displayName:l})=>{var n;const{customStyles:o}=L(),i=null===(n=null==o?void 0:o.userStoryCardStyles)||void 0===n?void 0:n.showDisplayName;return e("div",{className:A.displayName,style:null==i?void 0:i.wrapper,children:[t(w,{className:A.displayNameIcon,style:null==i?void 0:i.displayNameIcon}),e("span",{style:null==i?void 0:i.label,children:[l,":"]})]})},K=({isUserStoryCurrentlyUpdated:C,artifactId:I,artifactTitleId:b,parentUserStory:w,currentUserStory:O,onUserStoryChange:W,parentIndex:X,currentIndex:Y,enableDownload:ee,isDiffEditReviewMode:te,showUserStoryDiff:le,handleDownloadUserStory:ne,handleOpenSendDialog:oe,updateUserStoryArtifact:ie,selectedArtifactId:ae,isDisplayHighlightControl:re,elementDisplayConfig:se,_resolvedConfig:de,showWrapper:ue=!1,defaultExpanded:ce,actionItemsConfig:ve,onDelete:pe,contextVariant:me,expandedSubFeatures:ye,showDisplayName:he=!0,allowTitleEdit:fe=!0,showConfidenceScore:ge=!0,showBorderTop:Se=!0,sectionStatusConfig:Ce,showCompletionPanel:Ie=!1,showAddSectionButton:be=!1,disableEditPlan:we=!1,useMuiTooltip:Ne=!1,approveButtonConfig:De,CDNeededInChip:Ee,onAssignSectionClick:xe})=>{var Be,Te,Ae,Ue,ke,Pe,Re,_e,Fe,Me,Le,je,Ve,ze,Oe,We,$e,Ge;const{isLoadingSectionData:He=!1,onLoadSectionData:qe,status:Qe,onStatusClick:Ze,completedCount:Je,totalCount:Ke,isNoDataAvailable:Xe=!1}=null!=Ce?Ce:{},{searchQueryList:Ye,citations:et,customStyles:tt,onEditBlocked:lt,redlineDcoumentId:nt,redlineConfig:ot,customSectionConfig:it,updateRedlineDataParent:at}=L(),rt=null==tt?void 0:tt.userStoryCardStyles,st=null==rt?void 0:rt.customSectionEditButton,dt=null==rt?void 0:rt.statusStyles,ut=null===(Be=null==tt?void 0:tt.userStoryCardStyles)||void 0===Be?void 0:Be.userStoryEditStyles,ct=null===(Te=null==tt?void 0:tt.userStoryScreenStyles)||void 0===Te?void 0:Te.userStoryContentStyles,vt=null==rt?void 0:rt.progressHeaderStyles,pt=null==rt?void 0:rt.clinicalTrialSectionStyles,mt=null==rt?void 0:rt.CompletionStyles,yt=null==rt?void 0:rt.noDataStyles,ht=null==rt?void 0:rt.approveButtonStyles,ft=null!==(Ue=null===(Ae=null==it?void 0:it.shouldRender)||void 0===Ae?void 0:Ae.call(it,O))&&void 0!==Ue&&Ue,gt=null===(ke=null==it?void 0:it.getValue)||void 0===ke?void 0:ke.call(it,O),St=null!==(Re=null===(Pe=null==it?void 0:it.getFields)||void 0===Pe?void 0:Pe.call(it,O))&&void 0!==Re?Re:[],Ct=null!==(_e=null==it?void 0:it.isEditDisabled)&&void 0!==_e&&_e,It=null!==(Me=null===(Fe=null==it?void 0:it.isSaving)||void 0===Fe?void 0:Fe.call(it,O))&&void 0!==Me&&Me,bt=((e,t)=>e>=80?null==t?void 0:t.highCompletion:e>=50?null==t?void 0:t.mediumCompletion:null==t?void 0:t.lowCompletion)(null!==(Le=O.completion_percentage)&&void 0!==Le?Le:0,mt),wt={[M.WAITING]:null==dt?void 0:dt.waiting,[M.IN_PROGRESS]:null==dt?void 0:dt.inProgress,[M.GENERATED]:null==dt?void 0:dt.generated,[M.FAILED]:null==dt?void 0:dt.failed,[M.GENERATE]:null==dt?void 0:dt.generate,[M.APPROVED]:null==dt?void 0:dt.approved},[Nt,Dt]=n({...structuredClone(O),value:U(O.value)||""}),[Et,xt]=n({userStory:!!O.isDefaultEdit}),[Bt,Tt]=n(!1),[At,Ut]=n(!1),[kt,Pt]=n(null),[Rt,_t]=n(null),{userStory:Ft,customIcons:Mt}=L(),[Lt,jt]=n(null!=ce?ce:""===X||ae===O.artifactId||!!O.isDefaultOpen),[Vt,zt]=n(!1),[Ot,Wt]=n(null),[$t,Gt]=n(null),[Ht,qt]=n(!1),Qt=o(null),Zt=o(null),[Jt,Kt]=n(!1),[Xt,Yt]=n(!1),el=o(null),[tl,ll]=n(O.value);i(()=>{C&&jt(C)},[C]),i(()=>{Dt({...structuredClone(O),value:U(O.value)||""})},[O]),i(()=>{Ye.length>0?jt(!0):void 0===ce&&(ae?jt(ae===O.artifactId):ye&&ye.length>0&&jt(ye.includes(O.artifactId)))},[Ye,ae,O.artifactId,ye]);const nl=()=>{Wt(null)},ol=()=>{Gt(null)},il=()=>{Lt&&Et.userStory&&Zt.current&&!Zt.current.requestClose()||jt(e=>!e)},al=async()=>{var e;try{"userStory"==="userStory"&&(W(Nt),console.log("I am changing RTE editor values",Nt)),await ie(et,Ft,I,null===(e=el.current)||void 0===e?void 0:e.signal)}finally{}};const rl=null!=(null==O?void 0:O.big_enough)&&!Number.isNaN(O.big_enough)&&!!(null==O?void 0:O.big_enough_decision_factors),sl=null!==(je=null==O?void 0:O.completion_percentage)&&void 0!==je?je:0,dl=!!(null==O?void 0:O.completion_decision_factors),ul=""===X,cl=null!=de?de:Z(se,ul),vl=!te&&!le;i(()=>{if(!Rt)return;const e=setTimeout(()=>{const e=document.getElementById(`story-card-${Rt}`);null==e||e.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(e)},[Rt]),i(()=>{O.isDefaultEdit&&xt(e=>({...e,userStory:!0}))},[O.isDefaultEdit]);return i(()=>ll(O.value),[O.value]),e("div",{className:A.card,style:null==rt?void 0:rt.cardStyle,id:`story-card-${O.title}`,"data-expanded":Lt,children:[e("div",{className:A.titleSection,style:null==rt?void 0:rt.titleSection,children:[e("div",{className:A.titleRow,style:null==rt?void 0:rt.titleRow,onClick:il,children:[e("div",{className:A.titleLeft,style:null==rt?void 0:rt.titleLeft,onMouseEnter:()=>Kt(!0),onMouseLeave:()=>Kt(!1),children:[he&&t(J,{displayName:b}),Bt&&vl?t(V,{title:O.title,onSave:e=>(async(e,t)=>{var l;try{let n={...O};O.artifactId===t?n.title=e:n.sub_features=(null===(l=O.sub_features)||void 0===l?void 0:l.map(l=>l.artifactId===t?{...l,title:e}:l))||[],Dt(n),W(n),Tt(!1)}catch(e){console.error("Failed to save title",e)}})(e,O.artifactId),onCancel:()=>{Tt(!1)},inputStyle:null==ut?void 0:ut.inlineTitleInput,confirmButtonStyle:null==ut?void 0:ut.inlineTitleConfirm,cancelButtonStyle:null==ut?void 0:ut.inlineTitleCancel},"inline-title-editor"):e("div",{className:A.storyTitleWrapper,children:[t(D,{title:Q(O.title),arrow:!0,children:t("h2",{title:Ne?void 0:O.title,className:A.storyTitle,style:null==rt?void 0:rt.storyTitle,children:Q(O.title)},O.artifactId)}),Ie&&!ft&&(dl?t(G,{customIcons:null==Mt?void 0:Mt.userStoryIcons,customStyles:null==rt?void 0:rt.aiReasoningCitaionStyles,currentUserStory:O,panelStyles:null==rt?void 0:rt.CompletionStyles,onToggleStateChange:Yt,children:e("div",{style:{display:"inline-flex",alignItems:"center",gap:"4px",...null==mt?void 0:mt.badge,...bt},children:[e("span",{children:[sl,"% Completed"]}),t("span",{style:{display:"flex",alignItems:"center"},children:t(H,{color:"currentColor"})}),t(Xt?a:r,{size:14,style:null==mt?void 0:mt.chevronStyle})]})}):t("div",{style:{display:"inline-flex",alignItems:"center",gap:"4px",...null==mt?void 0:mt.badge,...bt},children:e("span",{children:[sl,"% Completed"]})})),fe&&t("button",{type:"button",className:A.titleEditButton,style:null==ut?void 0:ut.titleEditButton,onClick:e=>{e.stopPropagation(),Tt(!0),Lt||jt(!0)},"aria-label":"Edit title",title:"Edit title",children:t("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M8.99998 14.9992H15.75M2.25 14.9992H3.50591C3.87279 14.9992 4.05624 14.9992 4.22887 14.9577C4.38192 14.921 4.52824 14.8604 4.66245 14.7782C4.81382 14.6854 4.94354 14.5557 5.20296 14.2962L14.625 4.87419C15.2463 4.25287 15.2463 3.24551 14.625 2.62419C14.0037 2.00287 12.9963 2.00287 12.375 2.62419L2.95295 12.0462C2.69352 12.3057 2.5638 12.4354 2.47104 12.5868C2.3888 12.721 2.32819 12.8673 2.29145 13.0203C2.25 13.193 2.25 13.3764 2.25 13.7433V14.9992Z",stroke:"#94A3B8","stroke-width":"1.54286","stroke-linecap":"round","stroke-linejoin":"round"})})})]})]}),(Qe||void 0!==Je&&void 0!==Ke)&&e("div",{className:A.statusContainer,children:[void 0!==Je&&void 0!==Ke&&e("div",{className:A.completedBadge,children:["Completed: ",Je,"/",Ke]}),Qe&&t("button",{type:"button",onClick:e=>{e.stopPropagation(),null==Ze||Ze()},className:A.statusButton,style:wt[Qe],children:q[Qe]})]}),e("div",{className:A.titleActions,style:null==rt?void 0:rt.titleActions,onClick:e=>e.stopPropagation(),children:[(cl.showProgressPercentage||cl.showGapBox)&&ue&&e("div",{className:A.progressHeader,style:null==vt?void 0:vt.wrapper,children:[cl.showProgressPercentage&&e("div",{className:A.progressPercentage,style:null==vt?void 0:vt.percentage,children:[null!==(ze=null!==(Ve=null==O?void 0:O.confidenceScore)&&void 0!==Ve?Ve:null==cl?void 0:cl.confidenceValue)&&void 0!==ze?ze:"0","%"]}),cl.showGapBox&&e("div",{className:A.gapBox,style:null==vt?void 0:vt.gapBox,children:[null!==(We=null!==(Oe=null==O?void 0:O.gapValue)&&void 0!==Oe?Oe:null==cl?void 0:cl.gapBoxValue)&&void 0!==We?We:"2"," ","Gaps"]})]}),rl&&t(j,{customIcons:null==Mt?void 0:Mt.userStoryIcons,customStyles:null==rt?void 0:rt.aiReasoningCitaionStyles,currentUserStory:O,panelStyles:null==rt?void 0:rt.BigEnoughStyles}),t(D,{title:"Assign Section",arrow:!0,placement:"top",slotProps:{tooltip:{sx:{bgcolor:"#1E293B",color:"#FFFFFF",fontSize:"14px",fontWeight:400,px:2,py:2,borderRadius:"18px",boxShadow:"0px 8px 20px rgba(0,0,0,0.18)"}},arrow:{sx:{color:"#1E293B"}}},children:t("div",{style:{border:"1px solid #D1D5DB",padding:"5px 15px",borderRadius:"8px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",background:"#FFFFFF"},onClick:xe,children:e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#64748B",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-users-round-icon lucide-users-round",children:[t("path",{d:"M18 21a8 8 0 0 0-16 0"}),t("circle",{cx:"10",cy:"8",r:"5"}),t("path",{d:"M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3"})]})})}),!Et.userStory&&e(l,{children:[!1!==(null==cl?void 0:cl.showShareButton)&&t("button",{className:A.iconButton,style:null==rt?void 0:rt.iconButton,onClick:e=>{Wt(e.currentTarget)},children:t(s,{size:16})}),e(E,{id:"user-story-share-menu",anchorEl:Ot,open:!!Ot,onClose:()=>Wt(null),style:null==rt?void 0:rt.userStoryShareMenu,children:[ee&&t(x,{style:null==rt?void 0:rt.userStoryMenuItem,onClick:async()=>{zt(!0),ne&&(await Promise.all([ne("pdf"),ne("doc")]),zt(!1))},children:e("div",{ref:Qt,className:A.menuItemContent,style:null==rt?void 0:rt.menuItemContent,children:[t(d,{size:16,color:null==rt?void 0:rt.menuIconColor}),t("p",{style:null==rt?void 0:rt.menuLabel,children:"Download"})]})}),t(x,{style:null==rt?void 0:rt.userStoryMenuItem,onClick:async()=>{let e=O;w&&(e={...O,value:`${P(null==w?void 0:w.value,O.title)} \n${O.value}`}),null==oe||oe(!0,[e],O.artifactId),nl()},children:e("div",{style:null==rt?void 0:rt.menuItemContent,className:A.menuItemContentPadded,children:[t(u,{size:16,color:null==rt?void 0:rt.menuIconColor}),t("p",{style:null==rt?void 0:rt.menuLabel,children:"Send"})]})}),t(x,{style:null==rt?void 0:rt.userStoryMenuItem,onClick:async()=>{const e=(new N.Converter).makeHtml(U(O.value)||O.value),t=function(e){const t=(new N.Converter).makeHtml(e),l=document.createElement("div");return l.innerHTML=t,l.textContent||l.innerText||""}(U(O.value)||O.value),l=new ClipboardItem({"text/plain":new Blob([t],{type:"text/plain"}),"text/html":new Blob([e],{type:"text/html"})});try{await navigator.clipboard.write([l]),console.log("Copied User Story")}catch(e){console.error("Failed to copy user story:",e)}finally{nl()}},children:e("div",{style:null==rt?void 0:rt.menuItemContent,className:A.menuItemContentPadded,children:[t(c,{size:16,color:null==rt?void 0:rt.menuIconColor}),t("p",{style:null==rt?void 0:rt.menuLabel,children:"Copy"})]})})]})]}),!Ht&&Et.userStory&&Lt?t(R,{type:"outline",children:"Cancel",style:null==rt?void 0:rt.cancelButton,onClick:()=>{var e;null===(e=el.current)||void 0===e||e.abort(),xt(e=>({...e,userStory:!1}))}}):t(l,{}),Et.userStory&&Lt?t(R,{type:"fill",children:Ht?e("span",{className:A.savingSpinner,style:null==rt?void 0:rt.savingSpinner,children:[t(v,{className:A.spinAnimation,style:null==rt?void 0:rt.spinAnimation}),t("span",{children:"Saving..."})]}):"Save",isDisable:Ht,style:Ht?null==rt?void 0:rt.savingButton:null==rt?void 0:rt.saveButton,onClick:async()=>{qt(!0),await al();let e=await(async()=>{var e,t,l,n,o;let i=Nt.value;console.log("[V] valueToUpdate before",i),i=i.replace(/<invisible\s+id="([^"]+)"\s*><\/invisible>/gi,"\x3c!-- $1 --\x3e"),console.log("[V] valueToUpdate after",i);try{if(null==ot?void 0:ot.callUpdateDocument){const{updated_reqai:a}=await z({documentId:nt,sectionId:O.artifactId,baseApiUrl:null==ot?void 0:ot.baseApiUrl,updatedContent:i,userEmail:ot.userEmail,userName:ot.userName,redlineConfigId:null!==(e=ot.redlineConfigId)&&void 0!==e?e:""},null!==(t=null==ot?void 0:ot.token)&&void 0!==t?t:"");i=null===(o=null===(n=null===(l=null==a?void 0:a.artifactData)||void 0===l?void 0:l.userStorySnapshot)||void 0===n?void 0:n[0])||void 0===o?void 0:o.value,await(null==at?void 0:at(a))}}catch(e){console.error("failed to update redline document",e),i=tl}return i=i.replace(/<!--\s*([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\s*-->/gi,'<invisible id="$1"></invisible>'),i})();const t={...Nt,value:e};W({...t,isDefaultEdit:!1}),ll(t.value),xt(e=>({...e,userStory:!1})),qt(!1)}}):!te&&!le&&!we&&Lt&&!1!==(null==cl?void 0:cl.showEditButton)&&t("button",{className:A.iconButton,style:null==rt?void 0:rt.editButton,onClick:()=>xt(e=>({...e,userStory:!0})),children:t(p,{color:null==rt?void 0:rt.pencilIconColor,size:16})}),be&&ul&&Lt&&!te&&!le&&!1!==(null==cl?void 0:cl.showEditButton)&&e("button",{type:"button",className:A.addSectionButton,style:null==ut?void 0:ut.addSectionButton,onClick:e=>{var t,l,n;e.stopPropagation();const o=(null!==(l=null===(t=O.sub_features)||void 0===t?void 0:t.length)&&void 0!==l?l:0)+1,i={artifactId:T(),title:`New Section ${o}`,value:"Please add details for this section.",section:"subfeature",isDefaultOpen:!0},a={...O,sub_features:[...null!==(n=O.sub_features)&&void 0!==n?n:[],i]};Dt(a),W(a),jt(!0),_t(i.title)},"aria-label":"Add section",title:"Add section",children:[t(m,{size:14}),t("span",{className:A.addSectionLabel,children:"Add Section"})]}),!ul&&!te&&!we&&!le&&t("button",{type:"button",onClick:e=>{e.stopPropagation(),null==pe||pe()},className:A.iconButton,style:null==ut?void 0:ut.deleteButton,"aria-label":"Delete section",title:"Delete section",children:t(y,{size:16})}),ft&&t("button",{type:"button",className:A.iconButton,style:null==st?void 0:st.button,disabled:Ct,onClick:e=>{if(e.stopPropagation(),At)return Pt(null),void Ut(!1);Pt(structuredClone(null!=gt?gt:{})),jt(!0),Ut(!0)},children:At?t(h,{size:16,color:null==rt?void 0:rt.pencilIconColor,style:null==st?void 0:st.cancelIcon}):t(p,{size:16,color:null==rt?void 0:rt.pencilIconColor,style:null==st?void 0:st.editIcon})}),(null==cl?void 0:cl.actionItemsButton)&&e(l,{children:[t("span",{className:A.actionItemBtn,style:null==rt?void 0:rt.actionItemBtn,onClick:e=>{e.stopPropagation(),Gt(e.currentTarget)},children:t(f,{})}),t(E,{id:"user-story-action-menu",anchorEl:$t,open:!!$t,onClose:ol,style:null==rt?void 0:rt.userStoryShareMenu,children:null==ve?void 0:ve.items.map((l,n)=>t(x,{style:null==rt?void 0:rt.userStoryMenuItem,onClick:()=>{l.onclick(O),ol()},children:e("div",{className:A.menuItemContent,style:{...null==rt?void 0:rt.menuItemContent,...!l.isActive&&{cursor:"not-allowed",opacity:.5}},children:[t("span",{className:A.menuItemIcon,style:null==rt?void 0:rt.menuItemIcon,children:l.icon}),t("p",{style:null==rt?void 0:rt.menuLabel,children:l.name}),t("span",{className:A.menuItemRight,style:null==rt?void 0:rt.menuItemRight})]})},`action-item-${n}-${l.name}`))})]}),t("button",{type:"button",onClick:e=>{e.stopPropagation(),il()},style:null==rt?void 0:rt.chevronButton,className:A.chevronButton,children:t(Lt?a:r,{className:A.chevronIcon,color:null==rt?void 0:rt.chevronIconColor})})]})]}),t("div",{className:A.divider,style:null==rt?void 0:rt.dividerStyle})]}),Lt&&t("div",{className:A.cardContent,style:{...null==rt?void 0:rt.cardContentStyle,borderTop:Se?"1px solid #E5E5E5":"none"},children:e("div",He?{className:A.loadingContainer,children:[t("div",{className:A.loadingIconWrapper,children:t(g,{size:28,color:"#5B3DF5",className:A.spinAnimation})}),e("div",{children:[t("h3",{className:A.loadingTitle,children:"Section generation in progress.."}),t("p",{className:A.loadingSubtitle,children:"This may take a few minutes"})]}),t("button",{type:"button",onClick:()=>null==qe?void 0:qe(),className:A.viewStatusButton,children:"View Status"})]}:Xe?{className:A.noDataContainer,style:null==yt?void 0:yt.container,children:[t("img",{src:B,alt:"No data available",className:A.noDataIllustration,style:null==yt?void 0:yt.illustration}),t("h3",{className:A.noDataTitle,style:null==yt?void 0:yt.title,children:"No Data Available for This Section"}),t("p",{className:A.noDataSubtitle,style:null==yt?void 0:yt.subtitle,children:"We couldn't find data for this section yet. Upload the required document from the Documents tab to generate content."})]}:{className:A.contentInner,style:null==rt?void 0:rt.contentInner,children:[e("div",{className:A.descriptionSection,style:null==rt?void 0:rt.descriptionSection,children:[t("div",{className:A.justifyBetween,style:null==rt?void 0:rt.justifyBetween}),Et.userStory?t(_,{ref:Zt,minHeight:"100%",height:"100%",type:"string",value:U(tl)||"",handleUpdateState:(e,t)=>{const l=k(t);Dt(e=>({...e,value:l||""}))},doNotShowBorderInViewMode:!1,onBlur:()=>{},mode:Et.userStory?"edit":"readOnly",onEditBlocked:lt,onSaveUnsavedChanges:async()=>{await al(),jt(!1)},onDiscardUnsavedChanges:()=>{Dt({...structuredClone(O),value:U(O.value)||""}),xt(e=>({...e,userStory:!1})),jt(!1)},isSavingUnsavedChanges:Ht}):ft?t($,{styles:pt,fields:St,readonly:!At,isSaving:It,value:null!==($e=null!=kt?kt:gt)&&void 0!==$e?$e:{},onChange:Pt,onSave:async()=>{var e;kt&&(await(null===(e=null==it?void 0:it.onSave)||void 0===e?void 0:e.call(it,O,kt)),Pt(null),Ut(!1))},onCancel:()=>{Pt(null),Ut(!1)}}):e(l,{children:[t(F,{showUserStoryDiff:le,isParent:""===X,message:U(O.value)||"",artifactId:O.artifactId,customStyles:ct,isDisplayHighlightControl:re,contextVariant:me,showConfidenceScore:ge,CDNeededInChip:Ee}),De&&t("div",{className:A.approveButtonContainer,style:null==ht?void 0:ht.container,children:t("button",{type:"button",className:A.approveButton,style:null==ht?void 0:ht.button,disabled:De.disabled||De.isLoading,onClick:e=>{var t;e.stopPropagation(),null===(t=null==De?void 0:De.onClick)||void 0===t||t.call(De)},children:De.isLoading?e(l,{children:[t(v,{size:16,className:A.spinner,style:null==ht?void 0:ht.icon}),t("span",{style:null==ht?void 0:ht.text,children:De.label})]}):e(l,{children:[t("span",{style:null==ht?void 0:ht.text,children:De.label}),t(S,{size:16,style:null==ht?void 0:ht.icon})]})})})]})]}),null===(Ge=Nt.sub_features)||void 0===Ge?void 0:Ge.map((e,l)=>{const n=Z(se,!1,e.artifactId);return t(K,{artifactId:I,isUserStoryCurrentlyUpdated:C,artifactTitleId:`${b}-${String.fromCharCode(65+l)}`,parentUserStory:O,parentIndex:`${X}${X&&"."}${Y}`,currentIndex:`${l+1}`,doNotShowBorderInViewMode:!1,currentUserStory:e,onUserStoryChange:e=>((e,t)=>{const l=[...O.sub_features||[]];l[e]=t,W({...O,sub_features:l})})(l,e),enableDownload:!0,isDiffEditReviewMode:te,showUserStoryDiff:le,updateUserStoryArtifact:ie,handleDownloadUserStory:ne,handleOpenSendDialog:oe,isDisplayHighlightControl:re,elementDisplayConfig:se,_resolvedConfig:n,actionItemsConfig:ve,onDelete:()=>(e=>{const t=(O.sub_features||[]).filter((t,l)=>l!==e),l={...O,sub_features:t};Dt(l),W(l)})(l),expandedSubFeatures:ye,disableEditPlan:we,useMuiTooltip:Ne},e.artifactId)})]})})]})},X=({artifactTitleIDs:n,expandedSubFeatures:o,isDiffEditReviewMode:a,showUserStoryDiff:r,updateUserStoryArtifact:s,isUserStoryCurrentlyUpdated:d,artifactId:u,handleOpenSendDialog:c,handleDownloadUserStory:v,selectedArtifactId:p,isDisplayHighlightControl:m,elementDisplayConfig:y,showWrapper:h,actionItemsConfig:f,contextVariant:g,showDisplayName:S,allowTitleEdit:b,showConfidenceScore:w,showBorderTop:N,defaultExpanded:D,showCompletionPanel:E=!1,showAddSectionButton:x=!1,disableEditPlan:B=!1,useMuiTooltip:T=!1,approveButtonConfig:U,CDNeededInChip:k,setRedlineDocumentIdParent:P})=>{const{userStory:R,setUserStory:_,customStyles:F,searchQueryList:M,currentHighlightIndex:j,setCurrentHighlightIndex:V,segmentComponentConfig:z,sectionStatusConfig:$,redlineConfig:G,setRedlineDocumentId:H}=L(),q=null==F?void 0:F.userStoryCardStyles,Q=0===j,J=j===M.length-1;return i(()=>{if(!(null==G?void 0:G.callCreateDocumentOnInit))return;(async()=>{var e;const{redline_document_id:t}=await O({baseApiUrl:G.documentBaseApiUrl||"",comparisonId:G.documentComparisonId||""});if(t)H(t);else{const{document_id:t}=await W({baseApiUrl:G.baseApiUrl,changelogConfigId:G.changelogConfigId,comparisonId:G.documentComparisonId,artifactId:G.artifactId,inputData:G.inputData,redlineConfigId:G.redlineConfigId,userEmail:G.userEmail,userName:G.userName},null!==(e=null==G?void 0:G.token)&&void 0!==e?e:"");t&&(H(t),null==P||P(t))}})()},[]),e("div",{className:A.userStoryCardWrapper,style:m?{...null==q?void 0:q.userStoryCardWrapper,position:"relative"}:null==q?void 0:q.userStoryCardWrapper,children:[m&&t(l,{children:M.length>0&&t("div",{className:A.wrapper,children:t("div",{className:A.highlightNavigation,children:e("div",{className:A.navigationContainer,children:[e("span",{className:A.navCounter,children:[j+1," of ",M.length]}),e("div",{className:A.navButtons,children:[t("button",{onClick:()=>{j>0&&V(e=>e-1)},className:A.navButton,disabled:Q,children:t(C,{size:20,className:A.navIcon})}),t("button",{onClick:()=>{j<M.length-1&&V(e=>e+1)},className:A.navButton,disabled:J,children:t(I,{size:20,className:A.navIcon})})]})]})})})}),R.map((e,l)=>{const i=Z(y,!0);return t(K,{isUserStoryCurrentlyUpdated:d,artifactId:u,artifactTitleId:n[l]||"",expandedSubFeatures:o,currentUserStory:e,onUserStoryChange:e=>{_(t=>(t[l]=e,[...t]))},parentIndex:"",currentIndex:`${l+1}`,doNotShowBorderInViewMode:!0,enableDownload:!0,isDiffEditReviewMode:a,showUserStoryDiff:r,updateUserStoryArtifact:s,handleOpenSendDialog:c,handleDownloadUserStory:v,selectedArtifactId:p,isDisplayHighlightControl:m,elementDisplayConfig:y,_resolvedConfig:i,showWrapper:h,defaultExpanded:D,actionItemsConfig:f,contextVariant:g,showDisplayName:S,allowTitleEdit:b,showConfidenceScore:w,showBorderTop:N,sectionStatusConfig:$,showCompletionPanel:E,showAddSectionButton:x,disableEditPlan:B,useMuiTooltip:T,approveButtonConfig:U,CDNeededInChip:k},e.artifactId)})]})};export{K as StoryCard,X as UserStoryCardWrapper,K as default,Q as replaceLearnedTagsWithInfo};
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as l}from"react/jsx-runtime";import{useState as n,useRef as o,useEffect as i}from"react";import{ChevronUp as a,ChevronDown as r,ExternalLink as s,Download as d,Share2 as u,Copy as c,LoaderCircle as v,PencilIcon as p,Plus as m,Trash2 as y,X as h,Ellipsis as f,Hourglass as g,Check as S,ChevronUpIcon as C,ChevronDownIcon as I,Info as N,Bookmark as b}from"lucide-react";import w from"showdown";import{Tooltip as D,Menu as E,MenuItem as B}from"@mui/material";import x from"../../icons/Illustration.svg.js";import{v4 as T}from"uuid";import U from"./UserStoryCard.module.css.js";import{formatMarkdown as A,indentMarkdown as P}from"../../utils/helpers.js";import{replaceTitleSection as k}from"../../utils/user-story.utils.js";import R from"../../shared/AtomicButton.js";import _ from"../RichTextEditor/RichTextEditor.js";import M from"../userstory-with-citation/UserStoryWithCitation.js";import{SectionStatus as L,useRequirementAI as $}from"../RequirementAIWrapper/RequirementAIWrapper.js";import{BigEnoughPanel as V}from"../story-screen/BigEnoughPanel.js";import{InlineTitleEditor as j}from"./TitleEditor/TitleEditor.js";import{updateRedlineDocument as O,getRedlineDocumentId as z,createRedlineDocument as G}from"../../../../service/redlineService.js";import H from"./ClinicalTrialSection.js";import{CompletionPanel as W}from"../story-screen/CompletionPanel.js";import F from"../../icons/CDIcon.js";const q={[L.WAITING]:"WAITING TO GENERATE",[L.IN_PROGRESS]:"IN PROGRESS",[L.GENERATED]:"GENERATED",[L.FAILED]:"FAILED",[L.GENERATE]:"GENERATE",[L.APPROVED]:"APPROVED"};function Q(e){const l=[],n=/<learned>(.*?)<\/learned>/g;let o,i=0,a=0;for(;null!==(o=n.exec(e));){const[,r]=o,s=o.index;s>i&&l.push(t("span",{children:e.slice(i,s)},"text-pre-"+a++)),l.push(t(D,{title:r,placement:"top",children:t(N,{size:16,className:"inline-block mx-1 text-blue-500 hover:text-blue-700 cursor"})},`tooltip-${T()}`)),i=n.lastIndex}return i<(null==e?void 0:e.length)&&l.push(t("span",{children:e.slice(i)},"text-post-"+a++)),l}function Z(e,t,l){var n;if(!e)return{};if(t)return{...e.parentConfig};const o={...e.childConfig};return l&&(null===(n=e.subFeatureOverrides)||void 0===n?void 0:n[l])?{...o,...e.subFeatureOverrides[l]}:o}const J=({displayName:l})=>{var n;const{customStyles:o}=$(),i=null===(n=null==o?void 0:o.userStoryCardStyles)||void 0===n?void 0:n.showDisplayName;return e("div",{className:U.displayName,style:null==i?void 0:i.wrapper,children:[t(b,{className:U.displayNameIcon,style:null==i?void 0:i.displayNameIcon}),e("span",{style:null==i?void 0:i.label,children:[l,":"]})]})},K=({isUserStoryCurrentlyUpdated:C,artifactId:I,artifactTitleId:N,parentUserStory:b,currentUserStory:z,onUserStoryChange:G,parentIndex:X,currentIndex:Y,enableDownload:ee,isDiffEditReviewMode:te,showUserStoryDiff:le,handleDownloadUserStory:ne,handleOpenSendDialog:oe,updateUserStoryArtifact:ie,selectedArtifactId:ae,isDisplayHighlightControl:re,elementDisplayConfig:se,_resolvedConfig:de,showWrapper:ue=!1,defaultExpanded:ce,actionItemsConfig:ve,onDelete:pe,contextVariant:me,expandedSubFeatures:ye,showDisplayName:he=!0,allowTitleEdit:fe=!0,showConfidenceScore:ge=!0,showBorderTop:Se=!0,sectionStatusConfig:Ce,showCompletionPanel:Ie=!1,showAddSectionButton:Ne=!1,disableEditPlan:be=!1,useMuiTooltip:we=!1,approveButtonConfig:De,CDNeededInChip:Ee})=>{var Be,xe,Te,Ue,Ae,Pe,ke,Re,_e,Me,Le,$e,Ve,je,Oe,ze,Ge,He;const{isLoadingSectionData:We=!1,onLoadSectionData:Fe,status:qe,onStatusClick:Qe,completedCount:Ze,totalCount:Je,isNoDataAvailable:Ke=!1}=null!=Ce?Ce:{},{searchQueryList:Xe,citations:Ye,customStyles:et,onEditBlocked:tt,redlineDcoumentId:lt,redlineConfig:nt,customSectionConfig:ot,updateRedlineDataParent:it,aiReasoning:at}=$(),rt=null==et?void 0:et.userStoryCardStyles,st=null==rt?void 0:rt.customSectionEditButton,dt=null==rt?void 0:rt.statusStyles,ut=null===(Be=null==et?void 0:et.userStoryCardStyles)||void 0===Be?void 0:Be.userStoryEditStyles,ct=null===(xe=null==et?void 0:et.userStoryScreenStyles)||void 0===xe?void 0:xe.userStoryContentStyles,vt=null==rt?void 0:rt.progressHeaderStyles,pt=null==rt?void 0:rt.clinicalTrialSectionStyles,mt=null==rt?void 0:rt.CompletionStyles,yt=null==rt?void 0:rt.noDataStyles,ht=null==rt?void 0:rt.approveButtonStyles,ft=null!==(Ue=null===(Te=null==ot?void 0:ot.shouldRender)||void 0===Te?void 0:Te.call(ot,z))&&void 0!==Ue&&Ue,gt=null===(Ae=null==ot?void 0:ot.getValue)||void 0===Ae?void 0:Ae.call(ot,z),St=null!==(ke=null===(Pe=null==ot?void 0:ot.getFields)||void 0===Pe?void 0:Pe.call(ot,z))&&void 0!==ke?ke:[],Ct=null!==(Re=null==ot?void 0:ot.isEditDisabled)&&void 0!==Re&&Re,It=null!==(Me=null===(_e=null==ot?void 0:ot.isSaving)||void 0===_e?void 0:_e.call(ot,z))&&void 0!==Me&&Me,Nt=((e,t)=>e>=80?null==t?void 0:t.highCompletion:e>=50?null==t?void 0:t.mediumCompletion:null==t?void 0:t.lowCompletion)(null!==(Le=z.completion_percentage)&&void 0!==Le?Le:0,mt),bt={[L.WAITING]:null==dt?void 0:dt.waiting,[L.IN_PROGRESS]:null==dt?void 0:dt.inProgress,[L.GENERATED]:null==dt?void 0:dt.generated,[L.FAILED]:null==dt?void 0:dt.failed,[L.GENERATE]:null==dt?void 0:dt.generate,[L.APPROVED]:null==dt?void 0:dt.approved},[wt,Dt]=n({...structuredClone(z),value:A(z.value)||""}),[Et,Bt]=n({userStory:!!z.isDefaultEdit}),[xt,Tt]=n(!1),[Ut,At]=n(!1),[Pt,kt]=n(null),[Rt,_t]=n(null),{userStory:Mt,customIcons:Lt}=$(),[$t,Vt]=n(null!=ce?ce:""===X||ae===z.artifactId||!!z.isDefaultOpen),[jt,Ot]=n(!1),[zt,Gt]=n(null),[Ht,Wt]=n(null),[Ft,qt]=n(!1),Qt=o(null),Zt=o(null),[Jt,Kt]=n(!1),[Xt,Yt]=n(!1),el=o(null),[tl,ll]=n(z.value);i(()=>{C&&Vt(C)},[C]),i(()=>{Dt({...structuredClone(z),value:A(z.value)||""})},[z]),i(()=>{Xe.length>0?Vt(!0):void 0===ce&&(ae?Vt(ae===z.artifactId):ye&&ye.length>0&&Vt(ye.includes(z.artifactId)))},[Xe,ae,z.artifactId,ye]);const nl=()=>{Gt(null)},ol=()=>{Wt(null)},il=()=>{$t&&Et.userStory&&Zt.current&&!Zt.current.requestClose()||Vt(e=>!e)},al=async()=>{var e;try{"userStory"==="userStory"&&(G(wt),console.log("I am changing RTE editor values",wt)),await ie(Ye,Mt,I,null===(e=el.current)||void 0===e?void 0:e.signal)}finally{}};const rl=null!=(null==z?void 0:z.big_enough)&&!Number.isNaN(z.big_enough)&&!!(null==z?void 0:z.big_enough_decision_factors),sl=null!==($e=null==z?void 0:z.completion_percentage)&&void 0!==$e?$e:0,dl=!!(null==z?void 0:z.completion_decision_factors),ul=""===X,cl=null!=de?de:Z(se,ul),vl=!te&&!le;i(()=>{if(!Rt)return;const e=setTimeout(()=>{const e=document.getElementById(`story-card-${Rt}`);null==e||e.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(e)},[Rt]),i(()=>{z.isDefaultEdit&&Bt(e=>({...e,userStory:!0}))},[z.isDefaultEdit]);return i(()=>ll(z.value),[z.value]),e("div",{className:U.card,style:null==rt?void 0:rt.cardStyle,id:`story-card-${z.title}`,"data-expanded":$t,children:[e("div",{className:U.titleSection,style:null==rt?void 0:rt.titleSection,children:[e("div",{className:U.titleRow,style:null==rt?void 0:rt.titleRow,onClick:il,children:[e("div",{className:U.titleLeft,style:null==rt?void 0:rt.titleLeft,onMouseEnter:()=>Kt(!0),onMouseLeave:()=>Kt(!1),children:[he&&t(J,{displayName:N}),xt&&vl?t(j,{title:z.title,onSave:e=>(async(e,t)=>{var l;try{let n={...z};z.artifactId===t?n.title=e:n.sub_features=(null===(l=z.sub_features)||void 0===l?void 0:l.map(l=>l.artifactId===t?{...l,title:e}:l))||[],Dt(n),G(n),Tt(!1)}catch(e){console.error("Failed to save title",e)}})(e,z.artifactId),onCancel:()=>{Tt(!1)},inputStyle:null==ut?void 0:ut.inlineTitleInput,confirmButtonStyle:null==ut?void 0:ut.inlineTitleConfirm,cancelButtonStyle:null==ut?void 0:ut.inlineTitleCancel},"inline-title-editor"):e("div",{className:U.storyTitleWrapper,children:[t(D,{title:Q(z.title),arrow:!0,children:t("h2",{title:we?void 0:z.title,className:U.storyTitle,style:null==rt?void 0:rt.storyTitle,children:Q(z.title)},z.artifactId)}),Ie&&!ft&&(dl?t(W,{customIcons:null==Lt?void 0:Lt.userStoryIcons,customStyles:null==rt?void 0:rt.aiReasoningCitaionStyles,currentUserStory:z,panelStyles:null==rt?void 0:rt.CompletionStyles,onToggleStateChange:Yt,children:e("div",{style:{display:"inline-flex",alignItems:"center",gap:"4px",...null==mt?void 0:mt.badge,...Nt},children:[e("span",{children:[sl,"% Completed"]}),t("span",{style:{display:"flex",alignItems:"center"},children:t(F,{color:"currentColor"})}),t(Xt?a:r,{size:14,style:null==mt?void 0:mt.chevronStyle})]})}):t("div",{style:{display:"inline-flex",alignItems:"center",gap:"4px",...null==mt?void 0:mt.badge,...Nt},children:e("span",{children:[sl,"% Completed"]})})),fe&&t("button",{type:"button",className:U.titleEditButton,style:null==ut?void 0:ut.titleEditButton,onClick:e=>{e.stopPropagation(),Tt(!0),$t||Vt(!0)},"aria-label":"Edit title",title:"Edit title",children:t("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M8.99998 14.9992H15.75M2.25 14.9992H3.50591C3.87279 14.9992 4.05624 14.9992 4.22887 14.9577C4.38192 14.921 4.52824 14.8604 4.66245 14.7782C4.81382 14.6854 4.94354 14.5557 5.20296 14.2962L14.625 4.87419C15.2463 4.25287 15.2463 3.24551 14.625 2.62419C14.0037 2.00287 12.9963 2.00287 12.375 2.62419L2.95295 12.0462C2.69352 12.3057 2.5638 12.4354 2.47104 12.5868C2.3888 12.721 2.32819 12.8673 2.29145 13.0203C2.25 13.193 2.25 13.3764 2.25 13.7433V14.9992Z",stroke:"#94A3B8","stroke-width":"1.54286","stroke-linecap":"round","stroke-linejoin":"round"})})})]})]}),(qe||void 0!==Ze&&void 0!==Je)&&e("div",{className:U.statusContainer,children:[void 0!==Ze&&void 0!==Je&&e("div",{className:U.completedBadge,children:["Completed: ",Ze,"/",Je]}),qe&&t("button",{type:"button",onClick:e=>{e.stopPropagation(),null==Qe||Qe()},className:U.statusButton,style:bt[qe],children:q[qe]})]}),e("div",{className:U.titleActions,style:null==rt?void 0:rt.titleActions,onClick:e=>e.stopPropagation(),children:[(cl.showProgressPercentage||cl.showGapBox)&&ue&&e("div",{className:U.progressHeader,style:null==vt?void 0:vt.wrapper,children:[cl.showProgressPercentage&&e("div",{className:U.progressPercentage,style:null==vt?void 0:vt.percentage,children:[null!==(je=null!==(Ve=null==z?void 0:z.confidenceScore)&&void 0!==Ve?Ve:null==cl?void 0:cl.confidenceValue)&&void 0!==je?je:"0","%"]}),cl.showGapBox&&e("div",{className:U.gapBox,style:null==vt?void 0:vt.gapBox,children:[null!==(ze=null!==(Oe=null==z?void 0:z.gapValue)&&void 0!==Oe?Oe:null==cl?void 0:cl.gapBoxValue)&&void 0!==ze?ze:"2"," ","Gaps"]})]}),rl&&t(V,{customIcons:null==Lt?void 0:Lt.userStoryIcons,customStyles:null==rt?void 0:rt.aiReasoningCitaionStyles,currentUserStory:z,panelStyles:null==rt?void 0:rt.BigEnoughStyles}),!Et.userStory&&e(l,{children:[!1!==(null==cl?void 0:cl.showShareButton)&&t("button",{className:U.iconButton,style:null==rt?void 0:rt.iconButton,onClick:e=>{Gt(e.currentTarget)},children:t(s,{size:16})}),e(E,{id:"user-story-share-menu",anchorEl:zt,open:!!zt,onClose:()=>Gt(null),style:null==rt?void 0:rt.userStoryShareMenu,children:[ee&&t(B,{style:null==rt?void 0:rt.userStoryMenuItem,onClick:async()=>{Ot(!0),ne&&(await Promise.all([ne("pdf"),ne("doc")]),Ot(!1))},children:e("div",{ref:Qt,className:U.menuItemContent,style:null==rt?void 0:rt.menuItemContent,children:[t(d,{size:16,color:null==rt?void 0:rt.menuIconColor}),t("p",{style:null==rt?void 0:rt.menuLabel,children:"Download"})]})}),t(B,{style:null==rt?void 0:rt.userStoryMenuItem,onClick:async()=>{let e=z;b&&(e={...z,value:`${k(null==b?void 0:b.value,z.title)} \n${z.value}`}),null==oe||oe(!0,[e],z.artifactId),nl()},children:e("div",{style:null==rt?void 0:rt.menuItemContent,className:U.menuItemContentPadded,children:[t(u,{size:16,color:null==rt?void 0:rt.menuIconColor}),t("p",{style:null==rt?void 0:rt.menuLabel,children:"Send"})]})}),t(B,{style:null==rt?void 0:rt.userStoryMenuItem,onClick:async()=>{const e=(new w.Converter).makeHtml(A(z.value)||z.value),t=function(e){const t=(new w.Converter).makeHtml(e),l=document.createElement("div");return l.innerHTML=t,l.textContent||l.innerText||""}(A(z.value)||z.value),l=new ClipboardItem({"text/plain":new Blob([t],{type:"text/plain"}),"text/html":new Blob([e],{type:"text/html"})});try{await navigator.clipboard.write([l]),console.log("Copied User Story")}catch(e){console.error("Failed to copy user story:",e)}finally{nl()}},children:e("div",{style:null==rt?void 0:rt.menuItemContent,className:U.menuItemContentPadded,children:[t(c,{size:16,color:null==rt?void 0:rt.menuIconColor}),t("p",{style:null==rt?void 0:rt.menuLabel,children:"Copy"})]})})]})]}),!Ft&&Et.userStory&&$t?t(R,{type:"outline",children:"Cancel",style:null==rt?void 0:rt.cancelButton,onClick:()=>{var e;null===(e=el.current)||void 0===e||e.abort(),Bt(e=>({...e,userStory:!1}))}}):t(l,{}),Et.userStory&&$t?t(R,{type:"fill",children:Ft?e("span",{className:U.savingSpinner,style:null==rt?void 0:rt.savingSpinner,children:[t(v,{className:U.spinAnimation,style:null==rt?void 0:rt.spinAnimation}),t("span",{children:"Saving..."})]}):"Save",isDisable:Ft,style:Ft?null==rt?void 0:rt.savingButton:null==rt?void 0:rt.saveButton,onClick:async()=>{qt(!0),await al();let e=await(async()=>{var e,t,l,n,o;let i=wt.value;console.log("[V] valueToUpdate before",i),i=i.replace(/<invisible\s+id="([^"]+)"\s*><\/invisible>/gi,"\x3c!-- $1 --\x3e"),console.log("[V] valueToUpdate after",i);try{if(null==nt?void 0:nt.callUpdateDocument){const{updated_reqai:a}=await O({documentId:lt,sectionId:z.artifactId,baseApiUrl:null==nt?void 0:nt.baseApiUrl,updatedContent:i,userEmail:nt.userEmail,userName:nt.userName,redlineConfigId:null!==(e=nt.redlineConfigId)&&void 0!==e?e:""},null!==(t=null==nt?void 0:nt.token)&&void 0!==t?t:"");i=null===(o=null===(n=null===(l=null==a?void 0:a.artifactData)||void 0===l?void 0:l.userStorySnapshot)||void 0===n?void 0:n[0])||void 0===o?void 0:o.value,await(null==it?void 0:it(a))}}catch(e){console.error("failed to update redline document",e),i=tl}return i=i.replace(/<!--\s*([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\s*-->/gi,'<invisible id="$1"></invisible>'),i})();const t={...wt,value:e};G({...t,isDefaultEdit:!1}),ll(t.value),Bt(e=>({...e,userStory:!1})),qt(!1)}}):!te&&!le&&!be&&$t&&!1!==(null==cl?void 0:cl.showEditButton)&&t("button",{className:U.iconButton,style:null==rt?void 0:rt.editButton,onClick:()=>Bt(e=>({...e,userStory:!0})),children:t(p,{color:null==rt?void 0:rt.pencilIconColor,size:16})}),Ne&&ul&&$t&&!te&&!le&&!1!==(null==cl?void 0:cl.showEditButton)&&e("button",{type:"button",className:U.addSectionButton,style:null==ut?void 0:ut.addSectionButton,onClick:e=>{var t,l,n;e.stopPropagation();const o=(null!==(l=null===(t=z.sub_features)||void 0===t?void 0:t.length)&&void 0!==l?l:0)+1,i={artifactId:T(),title:`New Section ${o}`,value:"Please add details for this section.",section:"subfeature",isDefaultOpen:!0},a={...z,sub_features:[...null!==(n=z.sub_features)&&void 0!==n?n:[],i]};Dt(a),G(a),Vt(!0),_t(i.title)},"aria-label":"Add section",title:"Add section",children:[t(m,{size:14}),t("span",{className:U.addSectionLabel,children:"Add Section"})]}),!ul&&!te&&!be&&!le&&t("button",{type:"button",onClick:e=>{e.stopPropagation(),null==pe||pe()},className:U.iconButton,style:null==ut?void 0:ut.deleteButton,"aria-label":"Delete section",title:"Delete section",children:t(y,{size:16})}),ft&&t("button",{type:"button",className:U.iconButton,style:null==st?void 0:st.button,disabled:Ct,onClick:e=>{if(e.stopPropagation(),Ut)return kt(null),void At(!1);kt(structuredClone(null!=gt?gt:{})),Vt(!0),At(!0)},children:Ut?t(h,{size:16,color:null==rt?void 0:rt.pencilIconColor,style:null==st?void 0:st.cancelIcon}):t(p,{size:16,color:null==rt?void 0:rt.pencilIconColor,style:null==st?void 0:st.editIcon})}),(null==cl?void 0:cl.actionItemsButton)&&e(l,{children:[t("span",{className:U.actionItemBtn,style:null==rt?void 0:rt.actionItemBtn,onClick:e=>{e.stopPropagation(),Wt(e.currentTarget)},children:t(f,{})}),t(E,{id:"user-story-action-menu",anchorEl:Ht,open:!!Ht,onClose:ol,style:null==rt?void 0:rt.userStoryShareMenu,children:null==ve?void 0:ve.items.map((l,n)=>t(B,{style:null==rt?void 0:rt.userStoryMenuItem,onClick:()=>{l.onclick(z),ol()},children:e("div",{className:U.menuItemContent,style:{...null==rt?void 0:rt.menuItemContent,...!l.isActive&&{cursor:"not-allowed",opacity:.5}},children:[t("span",{className:U.menuItemIcon,style:null==rt?void 0:rt.menuItemIcon,children:l.icon}),t("p",{style:null==rt?void 0:rt.menuLabel,children:l.name}),t("span",{className:U.menuItemRight,style:null==rt?void 0:rt.menuItemRight})]})},`action-item-${n}-${l.name}`))})]}),t("button",{type:"button",onClick:e=>{e.stopPropagation(),il()},style:null==rt?void 0:rt.chevronButton,className:U.chevronButton,children:t($t?a:r,{className:U.chevronIcon,color:null==rt?void 0:rt.chevronIconColor})})]})]}),t("div",{className:U.divider,style:null==rt?void 0:rt.dividerStyle})]}),$t&&t("div",{className:U.cardContent,style:{...null==rt?void 0:rt.cardContentStyle,borderTop:Se?"1px solid #E5E5E5":"none"},children:e("div",We?{className:U.loadingContainer,children:[t("div",{className:U.loadingIconWrapper,children:t(g,{size:28,color:"#5B3DF5",className:U.spinAnimation})}),e("div",{children:[t("h3",{className:U.loadingTitle,children:"Section generation in progress.."}),t("p",{className:U.loadingSubtitle,children:"This may take a few minutes"})]}),t("button",{type:"button",onClick:()=>null==Fe?void 0:Fe(),className:U.viewStatusButton,children:"View Status"})]}:Ke?{className:U.noDataContainer,style:null==yt?void 0:yt.container,children:[t("img",{src:x,alt:"No data available",className:U.noDataIllustration,style:null==yt?void 0:yt.illustration}),t("h3",{className:U.noDataTitle,style:null==yt?void 0:yt.title,children:"No Data Available for This Section"}),t("p",{className:U.noDataSubtitle,style:null==yt?void 0:yt.subtitle,children:"We couldn't find data for this section yet. Upload the required document from the Documents tab to generate content."})]}:{className:U.contentInner,style:null==rt?void 0:rt.contentInner,children:[e("div",{className:U.descriptionSection,style:null==rt?void 0:rt.descriptionSection,children:[t("div",{className:U.justifyBetween,style:null==rt?void 0:rt.justifyBetween}),Et.userStory?t(_,{ref:Zt,minHeight:"100%",height:"100%",type:"string",value:A((pl=tl,pl.replace(/<(upt|manual)\s+id="([^"]+)"[^>]*>/gs,(e,t,l)=>{if(/\sdata-status=/.test(e))return e;const n=function(e){var t;const l=e.split("$"),n=l[1]||l[0];for(const e of at)if(e.id===n)return(null===(t=e.redlining_details)||void 0===t?void 0:t.status)||"";return""}(l);return e.replace(/>$/,` data-status="${n}">`)})))||"",handleUpdateState:(e,t)=>{const l=P(t);Dt(e=>({...e,value:l||""}))},doNotShowBorderInViewMode:!1,onBlur:()=>{},mode:Et.userStory?"edit":"readOnly",onEditBlocked:tt,onSaveUnsavedChanges:async()=>{await al(),Vt(!1)},onDiscardUnsavedChanges:()=>{Dt({...structuredClone(z),value:A(z.value)||""}),Bt(e=>({...e,userStory:!1})),Vt(!1)},isSavingUnsavedChanges:Ft}):ft?t(H,{styles:pt,fields:St,readonly:!Ut,isSaving:It,value:null!==(Ge=null!=Pt?Pt:gt)&&void 0!==Ge?Ge:{},onChange:kt,onSave:async()=>{var e;Pt&&(await(null===(e=null==ot?void 0:ot.onSave)||void 0===e?void 0:e.call(ot,z,Pt)),kt(null),At(!1))},onCancel:()=>{kt(null),At(!1)}}):e(l,{children:[t(M,{showUserStoryDiff:le,isParent:""===X,message:A(z.value)||"",artifactId:z.artifactId,customStyles:ct,isDisplayHighlightControl:re,contextVariant:me,showConfidenceScore:ge,CDNeededInChip:Ee}),De&&t("div",{className:U.approveButtonContainer,style:null==ht?void 0:ht.container,children:t("button",{type:"button",className:U.approveButton,style:null==ht?void 0:ht.button,disabled:De.disabled||De.isLoading,onClick:e=>{var t;e.stopPropagation(),null===(t=null==De?void 0:De.onClick)||void 0===t||t.call(De)},children:De.isLoading?e(l,{children:[t(v,{size:16,className:U.spinner,style:null==ht?void 0:ht.icon}),t("span",{style:null==ht?void 0:ht.text,children:De.label})]}):e(l,{children:[t("span",{style:null==ht?void 0:ht.text,children:De.label}),t(S,{size:16,style:null==ht?void 0:ht.icon})]})})})]})]}),null===(He=wt.sub_features)||void 0===He?void 0:He.map((e,l)=>{const n=Z(se,!1,e.artifactId);return t(K,{artifactId:I,isUserStoryCurrentlyUpdated:C,artifactTitleId:`${N}-${String.fromCharCode(65+l)}`,parentUserStory:z,parentIndex:`${X}${X&&"."}${Y}`,currentIndex:`${l+1}`,doNotShowBorderInViewMode:!1,currentUserStory:e,onUserStoryChange:e=>((e,t)=>{const l=[...z.sub_features||[]];l[e]=t,G({...z,sub_features:l})})(l,e),enableDownload:!0,isDiffEditReviewMode:te,showUserStoryDiff:le,updateUserStoryArtifact:ie,handleDownloadUserStory:ne,handleOpenSendDialog:oe,isDisplayHighlightControl:re,elementDisplayConfig:se,_resolvedConfig:n,actionItemsConfig:ve,onDelete:()=>(e=>{const t=(z.sub_features||[]).filter((t,l)=>l!==e),l={...z,sub_features:t};Dt(l),G(l)})(l),expandedSubFeatures:ye,disableEditPlan:be,useMuiTooltip:we},e.artifactId)})]})})]});var pl},X=({artifactTitleIDs:n,expandedSubFeatures:o,isDiffEditReviewMode:a,showUserStoryDiff:r,updateUserStoryArtifact:s,isUserStoryCurrentlyUpdated:d,artifactId:u,handleOpenSendDialog:c,handleDownloadUserStory:v,selectedArtifactId:p,isDisplayHighlightControl:m,elementDisplayConfig:y,showWrapper:h,actionItemsConfig:f,contextVariant:g,showDisplayName:S,allowTitleEdit:N,showConfidenceScore:b,showBorderTop:w,defaultExpanded:D,showCompletionPanel:E=!1,showAddSectionButton:B=!1,disableEditPlan:x=!1,useMuiTooltip:T=!1,approveButtonConfig:A,CDNeededInChip:P,setRedlineDocumentIdParent:k})=>{const{userStory:R,setUserStory:_,customStyles:M,searchQueryList:L,currentHighlightIndex:V,setCurrentHighlightIndex:j,segmentComponentConfig:O,sectionStatusConfig:H,redlineConfig:W,setRedlineDocumentId:F}=$(),q=null==M?void 0:M.userStoryCardStyles,Q=0===V,J=V===L.length-1;return i(()=>{if(!(null==W?void 0:W.callCreateDocumentOnInit))return;(async()=>{var e;const{redline_document_id:t}=await z({baseApiUrl:W.documentBaseApiUrl||"",comparisonId:W.documentComparisonId||""});if(t)F(t);else{const{document_id:t}=await G({baseApiUrl:W.baseApiUrl,changelogConfigId:W.changelogConfigId,comparisonId:W.documentComparisonId,artifactId:W.artifactId,inputData:W.inputData,redlineConfigId:W.redlineConfigId,userEmail:W.userEmail,userName:W.userName},null!==(e=null==W?void 0:W.token)&&void 0!==e?e:"");t&&(F(t),null==k||k(t))}})()},[]),e("div",{className:U.userStoryCardWrapper,style:m?{...null==q?void 0:q.userStoryCardWrapper,position:"relative"}:null==q?void 0:q.userStoryCardWrapper,children:[m&&t(l,{children:L.length>0&&t("div",{className:U.wrapper,children:t("div",{className:U.highlightNavigation,children:e("div",{className:U.navigationContainer,children:[e("span",{className:U.navCounter,children:[V+1," of ",L.length]}),e("div",{className:U.navButtons,children:[t("button",{onClick:()=>{V>0&&j(e=>e-1)},className:U.navButton,disabled:Q,children:t(C,{size:20,className:U.navIcon})}),t("button",{onClick:()=>{V<L.length-1&&j(e=>e+1)},className:U.navButton,disabled:J,children:t(I,{size:20,className:U.navIcon})})]})]})})})}),R.map((e,l)=>{const i=Z(y,!0);return t(K,{isUserStoryCurrentlyUpdated:d,artifactId:u,artifactTitleId:n[l]||"",expandedSubFeatures:o,currentUserStory:e,onUserStoryChange:e=>{_(t=>(t[l]=e,[...t]))},parentIndex:"",currentIndex:`${l+1}`,doNotShowBorderInViewMode:!0,enableDownload:!0,isDiffEditReviewMode:a,showUserStoryDiff:r,updateUserStoryArtifact:s,handleOpenSendDialog:c,handleDownloadUserStory:v,selectedArtifactId:p,isDisplayHighlightControl:m,elementDisplayConfig:y,_resolvedConfig:i,showWrapper:h,defaultExpanded:D,actionItemsConfig:f,contextVariant:g,showDisplayName:S,allowTitleEdit:N,showConfidenceScore:b,showBorderTop:w,sectionStatusConfig:H,showCompletionPanel:E,showAddSectionButton:B,disableEditPlan:x,useMuiTooltip:T,approveButtonConfig:A,CDNeededInChip:P},e.artifactId)})]})};export{K as StoryCard,X as UserStoryCardWrapper,K as default,Q as replaceLearnedTagsWithInfo};
|
|
2
2
|
//# sourceMappingURL=UserStoryCard.js.map
|
package/dist/features/RequirementAI/components/userstory-with-citation/UserStoryWithCitation.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e,Fragment as n,jsxs as i}from"react/jsx-runtime";import o,{createContext as t,useRef as l,useState as d,useCallback as r,useMemo as a,useEffect as s,useContext as c}from"react";import u from"react-markdown";import p from"rehype-raw";import g from"./UserStoryWithCitation.module.css.js";import{useMarkdownSearch as h}from"../../shared/useMarkdownSearch.js";import{Info as v}from"lucide-react";import{Tooltip as m}from"@mui/material";import C from"dompurify";import f from"../../shared/UpdatedAnimationContent.js";import y from"../../shared/GeneratedCodeCitation.js";import w from"../../shared/CitationLoadingIndicator.js";import{useRequirementAI as S}from"../RequirementAIWrapper/RequirementAIWrapper.js";import b from"../../icons/CognitiveDecision.js";import I from"../../icons/BrainRed.js";import R,{SHOW_CONFIDENCE_SCORE_THRESHOLD_IN_AI_REASONING as $}from"../ai-reasoning/AiReasoningCitation.js";import x from"../../icons/RelevanceScoreIcon.js";import N from"../RecommendationBlock/RecommendationBlock.js";import k from"../UserStoryCard/AttachedContext.js";import A from"../ai-reasoning/AiReasoningCitationContent.js";import j from"./components/InlineUpdatedComponent.js";import U from"../segment/SegmentWrapper.js";import{MarkdownContextProvider as E}from"../../store/markdown-context.js";import L from"./components/InlineManualComponent.js";import M from"./components/HighlightButtonComponent.js";const T=t(!1),P=t({expandedInfo:null,setExpanded:()=>{},reasonToRow:{current:new Map}}),D=t({rowId:""}),_=({aiReason:n,isHighConfidence:o,customStyle:t,customIcons:l})=>{var d;const{expandedInfo:r,setExpanded:a,reasonToRow:s}=c(P),{rowId:u}=c(D),p=String(n.id);u&&s.current.set(p,u);const h=(null===(d=null==r?void 0:r.aiReason)||void 0===d?void 0:d.id)===n.id,v=o?(null==l?void 0:l.highConfidence)||e(b,{}):(null==l?void 0:l.lowConfidence)||e(I,{});return i("button",{className:g.aiReasoningButton,style:t,onClick:e=>{e.stopPropagation(),e.preventDefault(),a(h?null:u,h?null:n)},children:[v,e("i",h?{className:`pi pi-angle-up ${o?g.aiReasoningIconHighConfidence:g.aiReasoningIconLowConfidence}`}:{className:`pi pi-angle-down ${o?g.aiReasoningIconHighConfidence:g.aiReasoningIconLowConfidence}`})]})},H=({children:n,node:o,customStyles:t,customIcons:d})=>{var r,a;const s=l(Math.random().toString(36).slice(2)).current,{expandedInfo:u}=c(P),p=(null==u?void 0:u.rowId)===s,h=Array.isArray(null==o?void 0:o.children)?o.children.filter(e=>"element"===e.type).length:1,v=null!==(a=null===(r=null==o?void 0:o.properties)||void 0===r?void 0:r.style)&&void 0!==a?a:void 0;return i(D.Provider,{value:{rowId:s},children:[e("tr",{style:v?{cssText:v}:void 0,children:n}),p&&(null==u?void 0:u.aiReason)&&e("tr",{style:{width:"100%"},children:e("td",{colSpan:h||1,className:g.tableExpandedCell,children:e("div",{className:g.tableExpandedCellInner,children:e("div",{className:g.tableExpandedCellContent,children:e(A,{aiReason:u.aiReason,customIcons:d,customStyles:{aiReasoningContent:null==t?void 0:t.aiReasoningContent,aiReasoningAccordion:null==t?void 0:t.aiReasoningAccordion,aiReasoningMarkdown:null==t?void 0:t.aiReasoningMarkdown,aiReasoningPill:null==t?void 0:t.aiReasoningPill,webCitation:null==t?void 0:t.webCitation,stormeeCitation:null==t?void 0:t.stormeeCitation,waveformCitation:null==t?void 0:t.waveformCitation,imageCitation:null==t?void 0:t.imageCitation,fileCitation:null==t?void 0:t.fileCitation,appModCitation:null==t?void 0:t.appModCitation,rcaCitation:null==t?void 0:t.rcaCitation,readFileCitation:null==t?void 0:t.readFileCitation,loadingCitations:null==t?void 0:t.loadingCitations,chatCitation:null==t?void 0:t.chatCitation}})})})})})]})};const F=["del","ins"];function B(e){return function(e,n,i){const o=n.join("|");return e.replace(new RegExp(`<(${o})>([\\s\\S]*?)<\\/\\1>`,"gi"),(e,n,o)=>`<${n}>${i(o)}</${n}>`)}(e,F,e=>e.split(/(<[^>]+>)/g).map(e=>!e||/^<[^>]+>$/.test(e)?e:function(e){if(!e)return e;const n=[];return e.replace(/`([^`\n]+)`/g,(e,i)=>`@@CODE_SPAN_${n.push(i)-1}@@`).replace(/\*\*([\s\S]+?)\*\*/g,"<strong>$1</strong>").replace(/__([\s\S]+?)__/g,"<strong>$1</strong>").replace(/@@CODE_SPAN_(\d+)@@/g,(e,i)=>{var o;return`<code>${t=null!==(o=n[Number(i)])&&void 0!==o?o:"",t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}</code>`;var t})}(e)).join(""))}const O=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function V(e,n){const i=[],t=new Set(n.map(e=>e.toLowerCase())),l=e=>{var n,d;try{if(null==e||"boolean"==typeof e)return null;if("string"==typeof e||"number"==typeof e)return e;if(Array.isArray(e))return e.map(e=>l(e)).flat().filter(e=>null!=e);if(!o.isValidElement(e))return e;const r="string"==typeof e.type?e.type.toLowerCase():"";if(t.has(r))return i.push(e),null;if(O.has(r))return e;const a=null===(d=o.Children.map(null===(n=e.props)||void 0===n?void 0:n.children,l))||void 0===d?void 0:d.flat().filter(e=>null!=e);return a&&0!==a.length?o.cloneElement(e,void 0,a):null}catch(n){return console.error("splitNestedDiffNodes failed while processing node:",n),e}};try{return{cleanedChildren:l(e),extractedNodes:i}}catch(n){return console.error("splitNestedDiffNodes failed:",n),{cleanedChildren:e,extractedNodes:[]}}}const q=({message:t,noMarkdownContent:b,useMarkdown:I=!0,isParent:A,scenario:D,showUserStoryDiff:F=!1,aiReasoningsForBlock:O,isCitationLoadingDisplay:q=!1,className:z,highConfidenceIcon:W,lowConfidenceIcon:G,customStyles:Q,customIcons:J,contextVariant:K,aiReasoningDiffView:X,userStoryCitations:Y,artifactId:Z,isCraflow:ee,onCraAccept:ne,onCraReject:ie,craFlowConfig:oe,isDisplayHighlightControl:te=!1,showConfidenceScore:le=!0,CDNeededInChip:de})=>{var re;const ae=l(null),{userStory:se,inlineUpdateComponentConfig:ce,getAvgScoreForStory:ue,setUserStory:pe,aiReasoning:ge,setAiReasoning:he,customIcons:ve,searchQueryList:me,searchQueryReasoningIdList:Ce,currentHighlightIndex:fe,segmentComponentConfig:ye,inlineManualComponentConfig:we,diffEditConfig:Se}=S(),be=null!=J?J:null==ve?void 0:ve.userStoryIcons;null==Q||Q.searchHighlight;const{search:Ie,clear:Re}=h(ae),[$e,xe]=d("1"),[Ne,ke]=d(null),Ae=l(new Map),[je,Ue]=d(new Set),Ee=r((e,n)=>{ke(e&&n?{rowId:e,aiReason:n}:null)},[]),Le=Z?ue(Z):0,[Me,Te]=d([]),Pe=r(e=>{Ue(n=>{const i=new Set(n);return i.has(e)?i.delete(e):i.add(e),i})},[]),De=e=>null==e?"":"string"==typeof e?e:"number"==typeof e?String(e):Array.isArray(e)?e.map(De).join(""):o.isValidElement(e)?De(e.props.children):"",_e=e=>{let n=e;return n=n.replace(/<deleted>([\s\S]*?)<\/deleted>/gi,(e,n)=>`<deleted>${n.replace(/ai_reasoning\$(\d+)/g,(e,n)=>`ai_reasoning$${n}-legacy`)}</deleted>`),n=n.replace(/<generatedCode([^>]*)>([\s\S]*?)<\/generatedCode>/gi,(e,n,i)=>`\n\n<generatedCode${n} data-raw="${btoa(encodeURIComponent(i.trim()))}"></generatedCode>\n\n`),n=n.replace(/^(\s*[-*]|\s*\d+\.)\s*\n?\s*(<updated\b)/gm,"$1 $2"),n=n.replace(/(<segment\b([^>]*)>)([\s\S]*?)(<\/segment>)/gi,(e,n,i,o,t)=>{const l=o.match(/<table[\s\S]*?<\/table>/i);if(l){return`<segment${i} data-table="${btoa(encodeURIComponent(l[0]))}"></segment>`}return e}),n=n.replace(/<updatedsegment([^>]*)>([\s\S]*?)<\/updatedsegment>/gi,(e,n,i)=>{if(/<table[\s>]/i.test(i)){return`<updatedsegment${n} data-raw="${btoa(encodeURIComponent(i))}"></updatedsegment>`}return e}),n=n.replace(/<updated([^>]*)>([\s\S]*?)<\/updated>/gi,(e,i,o,t)=>{const l=n.substring(0,t),d=l.lastIndexOf("\n"),r=/^\s+[-*]\s/.test(l.substring(d+1))||/^\s+\d+\.\s/.test(l.substring(d+1)),a=/^\s*(\d+\.|\s*[-*])\s+$/.test(l.substring(d+1));if(r||a){let e=o;return e=e.replace(/(<deleted>)\s*\n?\s*[-*]\s+/gi,"$1\n"),e=e.replace(/(<changed>)\s*\n?\s*[-*]\s+/gi,"$1\n"),e=e.replace(/(<deleted>)\s*\n?\s*\d+\.\s+/gi,"$1\n"),e=e.replace(/(<changed>)\s*\n?\s*\d+\.\s+/gi,"$1\n"),`<updated${i}>${e}</updated>`}return e}),n=function(e){const n=/<updated[^>]*>[\s\S]*?<\/updated>/gi,i=[];let o;const t=new RegExp(n.source,n.flags);for(;null!==(o=t.exec(e));){const e=o[0],n=e.match(/<deleted>([\s\S]*?)<\/deleted>/i),t=e.match(/<changed>([\s\S]*?)<\/changed>/i),l=e=>(e.match(/^\s*\d+\.\s/gm)||[]).length;i.push({index:o.index,endIndex:o.index+o[0].length,deletedItemCount:l((null==n?void 0:n[1])||""),changedItemCount:l((null==t?void 0:t[1])||"")})}if(0===i.length)return e;let l=e;for(let e=i.length-1;e>=0;e--){const n=i[e],o=n.changedItemCount-n.deletedItemCount;if(0===o)continue;const t=l.substring(0,n.index).split("\n").reverse();let d=!1;for(const e of t){const n=e.trim();if(""!==n){/^\d+\.\s/.test(n)&&(d=!0);break}}if(!d)continue;const r=n.endIndex,a=e+1<i.length?i[e+1].index:l.length;let s=l.substring(r,a);s=s.replace(/^(\s*)(\d+)\.\s/gm,(e,n,i)=>`${n}${parseInt(i,10)+o}. `),l=l.substring(0,r)+s+l.substring(a)}return l}(n),n=function(e){let n=e.replace(/<deleted>([\s\S]*?)<\/deleted>/gi,(e,n)=>{const i=n.replace(/\n{2,}/g,"\n");return console.log("[normalizeCustomTags] collapseNewlines in <deleted>",{hadChange:i!==n}),`<deleted>${i}</deleted>`});return n=n.replace(/<changed>([\s\S]*?)<\/changed>/gi,(e,n)=>{const i=n.replace(/\n{2,}/g,"\n");return console.log("[normalizeCustomTags] collapseNewlines in <changed>",{hadChange:i!==n,preview:n.substring(0,120)}),`<changed>${i}</changed>`}),n}(n),n=B(n),n},He=a(()=>t?_e(t):t,[t]);s(()=>{Te(O||ge)},[O,ge]);const Fe=a(()=>({span:({node:n,children:i,...o})=>{var t,l,d,r,a;const s=null!==(l=null===(t=null==n?void 0:n.properties)||void 0===t?void 0:t["highlight-id"])&&void 0!==l?l:null==o?void 0:o["highlight-id"],c="string"==typeof s&&je.has(s),u=null!==(r=null===(d=null==n?void 0:n.properties)||void 0===d?void 0:d["highlight-color"])&&void 0!==r?r:null==o?void 0:o["highlight-color"];return e("span",{style:{...null!==(a=null==Q?void 0:Q.span)&&void 0!==a?a:{},...c?{backgroundColor:u||"#fef08a"}:{}},children:i})},button:({node:i,children:o,...t})=>{var l,d,r,a,s,c;const u=null!==(d=null===(l=null==i?void 0:i.properties)||void 0===l?void 0:l.action)&&void 0!==d?d:null==t?void 0:t.action,p=null!==(a=null===(r=null==i?void 0:i.properties)||void 0===r?void 0:r["highlight-id"])&&void 0!==a?a:null==t?void 0:t["highlight-id"],g=null!==(c=null===(s=null==i?void 0:i.properties)||void 0===s?void 0:s["highlight-type"])&&void 0!==c?c:null==t?void 0:t["highlight-type"];return"highlight"===u?e(M,{highlightId:p,handleHighlightSpan:Pe,icon:"web"===g?null==be?void 0:be.webCitationIcon:"doc"===g?null==be?void 0:be.fileCitationIcon:e(n,{}),customStyles:"web"===g?null==Q?void 0:Q.webButton:"doc"===g?null==Q?void 0:Q.docButton:{}}):null},upt:({node:i,children:o,...t})=>{var l;const d=null==t?void 0:t.id,r=d?null===(l=d.split("$"))||void 0===l?void 0:l[1]:null,a=ge.find(e=>e.id.toString()===r);return a?e(n,{children:e(j,{aiReason:a,customStyles:null==Q?void 0:Q.inlineUpdatedComponent,handleClickCognitiveDecision:null==ce?void 0:ce.handleClickCognitiveDecision,handleClickUpdatedPill:null==ce?void 0:ce.handleClickUpdatedPill,handleClickOutputValue:null==ce?void 0:ce.handleClickOutputValue,customIcons:null==ce?void 0:ce.customIcons,CDNeededInChip:de,children:o||e(n,{})})}):o||e(n,{})},del:({node:o,children:t,...l})=>{var d;const{cleanedChildren:r,extractedNodes:a}=V(t,["ins"]);return i(n,{children:[e("span",{className:g.deleted,style:null!==(d=null==Q?void 0:Q.deleted)&&void 0!==d?d:{},...l,onClick:()=>{l.onclick&&l.onclick()},children:r}),a]})},ins:({children:o,...t})=>{var l;const{cleanedChildren:d,extractedNodes:r}=V(o,["del"]);return i(n,{children:[e("span",{className:g.inserted,style:null!==(l=null==Q?void 0:Q.inserted)&&void 0!==l?l:{},...t,onClick:()=>{t.onclick&&t.onclick()},children:d}),r]})},preserved:({children:n,...i})=>e("span",{className:g.preserved,style:null==Q?void 0:Q.preserved,...i,children:n}),manual:({children:n,...i})=>{const o=null==i?void 0:i.id,t=ge.find(e=>e.id.toString()===o);return t?e(L,{aiReason:t,handleClick:null==we?void 0:we.handleClick,children:n}):n},invisible:({children:i,...o})=>e(n,{}),h1:({node:n,...i})=>e("h1",{className:g.heading1,style:null==Q?void 0:Q.heading1,children:i.children}),h2:({node:n,...i})=>e("h2",{className:g.heading2,style:null==Q?void 0:Q.heading2,children:i.children}),h3:({node:n,...i})=>e("h3",{className:g.heading3,style:null==Q?void 0:Q.heading3,children:i.children}),b:({node:n,...i})=>e("b",{className:g.bold,style:null==Q?void 0:Q.bold,children:null==i?void 0:i.children}),p:({node:n,...i})=>e("p",{...i,className:g.paragraph,style:null==Q?void 0:Q.paragraph,children:i.children}),updated:({node:n,...i})=>e(f,{...i,showUserStoryDiff:F,currentUpdatedTagId:$e,setCurrentUpdatedTagId:xe,userStory:se,setUserStory:pe,setAiReasoning:he,node:n,isCraflow:ee,onCraAccept:ne,onCraReject:ie,diffEditConfig:Se,customStyles:null==Q?void 0:Q.updatedContent,craFlowConfig:oe}),ol:({node:n,...i})=>{var o,t,l;const d=null!==(l=null!==(t=null===(o=null==n?void 0:n.properties)||void 0===o?void 0:o.start)&&void 0!==t?t:null==i?void 0:i.start)&&void 0!==l?l:void 0;return e("ol",{className:g.orderedList,style:null==Q?void 0:Q.olist,...d?{start:Number(d)}:{},children:null==i?void 0:i.children})},ul:({node:n,...i})=>e("ul",{className:g.unorderedList,style:null==Q?void 0:Q.ulist,children:null==i?void 0:i.children}),table:({children:n})=>e("div",{className:g.tableWrapper,children:e("table",{className:g.table,style:null==Q?void 0:Q.table,children:n})}),tr:({node:n,children:i})=>e(H,{node:n,children:i,customStyles:Q}),td:({node:n,children:i})=>{var o;const{style:t,...l}=null!==(o=null==n?void 0:n.properties)&&void 0!==o?o:{};return e(T.Provider,{value:!0,children:e("td",{...l,style:t?{cssText:t}:void 0,children:i})})},th:({node:n,children:i})=>{var o;const{style:t,...l}=null!==(o=null==n?void 0:n.properties)&&void 0!==o?o:{};return e(T.Provider,{value:!0,children:e("th",{...l,style:t?{cssText:t}:void 0,children:i})})},recommendation:({node:n,...i})=>{var o;const t=`The AI has selected this content based on: ${(null===(o=null==i?void 0:i.children)||void 0===o?void 0:o[0])||""}`;return e(N,{...i,customStyles:null==Q?void 0:Q.recommendationBlock,label:t})},a:({inline:n,children:i,node:o,...t})=>{var l,d,r;const a=c(T)||"true"==(null==t?void 0:t.table),s=`${null==t?void 0:t.href}`,u=null===(l=s.split("$"))||void 0===l?void 0:l[0],p=null===(d=s.split("$"))||void 0===d?void 0:d[1];if("ai_reasoning"===u){const n=(null!==(r=F?X:ge)&&void 0!==r?r:[]).find(e=>e.id.toString()===decodeURIComponent(p)),o=Ce.includes(p);if(n){if(a)return e(_,{aiReason:n,customStyle:null==Q?void 0:Q.tableAiReasoning,customIcons:be,isHighConfidence:n.relevance_score>=$});const t=De(i),l="source"!==t.trim().toLowerCase();return e(R,{aiReason:n,isSourceHasHighlight:o,inlineLabel:t,isInlineCitation:l,customIcons:be,customStyles:{aiReasoningContent:null==Q?void 0:Q.aiReasoningContent,aiReasoningAccordion:null==Q?void 0:Q.aiReasoningAccordion,aiReasoningMarkdown:null==Q?void 0:Q.aiReasoningMarkdown,aiReasoningPill:null==Q?void 0:Q.aiReasoningPill,webCitation:null==Q?void 0:Q.webCitation,stormeeCitation:null==Q?void 0:Q.stormeeCitation,waveformCitation:null==Q?void 0:Q.waveformCitation,imageCitation:null==Q?void 0:Q.imageCitation,fileCitation:null==Q?void 0:Q.fileCitation,appModCitation:null==Q?void 0:Q.appModCitation,rcaCitation:null==Q?void 0:Q.rcaCitation,readFileCitation:null==Q?void 0:Q.readFileCitation,loadingCitations:null==Q?void 0:Q.loadingCitations,chatCitation:null==Q?void 0:Q.chatCitation,bigEnoughCitation:null==Q?void 0:Q.bigEnoughCitation}})}}return null},code:({inline:n,children:i,className:o,node:t,...l})=>/language-(\w+)/.exec(o||"")||(null==o?void 0:o.includes("language-"))?e("div",{children:e("code",{className:g.blockCode,style:null==Q?void 0:Q.code,children:i})}):e("code",{className:g.inlineCode,style:null==Q?void 0:Q.code,children:i}),learned:({children:n})=>e(m,{title:n,placement:"top",children:e(v,{size:16,className:g.learned})}),generatedcode:({node:n,...i})=>{const o=(null==i?void 0:i.language)||"python",t=(e=>{let n="";try{if(e["data-raw"])n=decodeURIComponent(atob(e["data-raw"]));else{const i=e=>{var n;return"string"==typeof e?e:Array.isArray(e)?e.map(i).join(""):(null===(n=null==e?void 0:e.props)||void 0===n?void 0:n.children)?i(e.props.children):""};n=i(e.children)}}catch(i){console.error("Error decoding generated code:",i),n=String(e.children)}return n})(i);return e(y,{title:"Generated Code",code:t,language:o,customStyles:{pill:null==Q?void 0:Q.generatedCodePill,content:null==Q?void 0:Q.generatedCodeContent}})},updatedsegment:({node:n,children:i,...o})=>{var t,l,d,r;const a=`${null===(t=n.position)||void 0===t?void 0:t.start.line}-${null===(l=n.position)||void 0===l?void 0:l.start.column}-${null===(d=n.position)||void 0===d?void 0:d.end.line}-${null===(r=n.position)||void 0===r?void 0:r.end.column}`,s=(e=>{if(!e["data-raw"])return null;try{return decodeURIComponent(atob(e["data-raw"]))}catch(e){return console.error("Error decoding segment raw content:",e),null}})(o),c=e("div",s?{dangerouslySetInnerHTML:{__html:C.sanitize(s)}}:{children:i});return e(U,{id:a,node:n,children:c,props:o,segmentComponentConfig:ye,customStyles:Q,customIcons:J,extractText:De,isUpdatedSegment:!0})},segment:({node:n,children:i,...o})=>{var t,l,d,r;const a=`${null===(t=n.position)||void 0===t?void 0:t.start.line}-${null===(l=n.position)||void 0===l?void 0:l.start.column}-${null===(d=n.position)||void 0===d?void 0:d.end.line}-${null===(r=n.position)||void 0===r?void 0:r.end.column}`;return e(U,{id:a,node:n,children:i,props:o,segmentComponentConfig:ye,customStyles:Q,customIcons:J,extractText:De})}}),[Me,oe,ge,Y,$e,F,t,J,me,Ce,Q,ye,je,Pe]);return s(()=>{if(!ae.current)return;if(!me.length)return void Re();let e;if(0===Ce.length||te)requestAnimationFrame(()=>{Ie([me[fe].replace(/\*/g,"")])});else{const n=ae.current,i=new MutationObserver(()=>{clearTimeout(e),e=setTimeout(()=>{i.disconnect(),requestAnimationFrame(()=>{Ie([me[fe].replace(/\*/g,"")])})},50)});i.observe(n,{childList:!0,subtree:!0})}return()=>{clearTimeout(e)}},[me,Ce,fe,te]),e(P.Provider,{value:{expandedInfo:Ne,setExpanded:Ee,reasonToRow:Ae},children:i("div",{ref:ae,className:`${g.container} ${"approving"!==D?g.wrapper:""} ${z||""}`,style:null==Q?void 0:Q.container,children:[I?e(E,{children:e(u,{components:Fe,rehypePlugins:[p],children:He})}):b,Le>0&&le&&e("div",{className:g.confidenceScoreContainer,style:null==Q?void 0:Q.confidenceScoreContainer,children:i("span",{className:g.confidenceScore,style:null==Q?void 0:Q.confidenceScore,children:[e(x,{size:14,color:(null==Q?void 0:Q.confidenceScoreIconColor)||"#166534"}),Le,"%"]})}),q&&e("div",{className:g.citationLoader,style:null==Q?void 0:Q.citationLoaderContainer,children:e(w,{customStyles:{container:null==Q?void 0:Q.citationLoadingContainer,icon:null==Q?void 0:Q.citationLoadingIcon,text:null==Q?void 0:Q.citationLoadingText}})}),A&&e("div",{style:{...null===(re=null==Q?void 0:Q.attachedContext)||void 0===re?void 0:re.wrapper},className:"flex mt-5",children:e(k,{customStyles:null==Q?void 0:Q.attachedContext,variant:K})})]})})};export{q as default,V as splitNestedDiffNodes};
|
|
1
|
+
import{jsx as e,Fragment as n,jsxs as i}from"react/jsx-runtime";import o,{createContext as t,useRef as l,useState as r,useCallback as d,useMemo as a,useEffect as s,useContext as c}from"react";import u from"react-markdown";import p from"rehype-raw";import g from"./UserStoryWithCitation.module.css.js";import{useMarkdownSearch as h}from"../../shared/useMarkdownSearch.js";import{Info as v}from"lucide-react";import{Tooltip as m}from"@mui/material";import C from"dompurify";import f from"../../shared/UpdatedAnimationContent.js";import y from"../../shared/GeneratedCodeCitation.js";import w from"../../shared/CitationLoadingIndicator.js";import{useRequirementAI as S}from"../RequirementAIWrapper/RequirementAIWrapper.js";import b from"../../icons/CognitiveDecision.js";import I from"../../icons/BrainRed.js";import R,{SHOW_CONFIDENCE_SCORE_THRESHOLD_IN_AI_REASONING as $}from"../ai-reasoning/AiReasoningCitation.js";import x from"../../icons/RelevanceScoreIcon.js";import N from"../RecommendationBlock/RecommendationBlock.js";import k from"../UserStoryCard/AttachedContext.js";import A from"../ai-reasoning/AiReasoningCitationContent.js";import j from"./components/InlineUpdatedComponent.js";import U from"../segment/SegmentWrapper.js";import{MarkdownContextProvider as E}from"../../store/markdown-context.js";import L from"./components/InlineManualComponent.js";import M from"./components/HighlightButtonComponent.js";import{escapeTagIds as T,splitTagAcrossParagraphs as P}from"../../../../utils/tagHelper.js";const D=t(!1),_=t({expandedInfo:null,setExpanded:()=>{},reasonToRow:{current:new Map}}),H=t({rowId:""}),F=({aiReason:n,isHighConfidence:o,customStyle:t,customIcons:l})=>{var r;const{expandedInfo:d,setExpanded:a,reasonToRow:s}=c(_),{rowId:u}=c(H),p=String(n.id);u&&s.current.set(p,u);const h=(null===(r=null==d?void 0:d.aiReason)||void 0===r?void 0:r.id)===n.id,v=o?(null==l?void 0:l.highConfidence)||e(b,{}):(null==l?void 0:l.lowConfidence)||e(I,{});return i("button",{className:g.aiReasoningButton,style:t,onClick:e=>{e.stopPropagation(),e.preventDefault(),a(h?null:u,h?null:n)},children:[v,e("i",h?{className:`pi pi-angle-up ${o?g.aiReasoningIconHighConfidence:g.aiReasoningIconLowConfidence}`}:{className:`pi pi-angle-down ${o?g.aiReasoningIconHighConfidence:g.aiReasoningIconLowConfidence}`})]})},B=({children:n,node:o,customStyles:t,customIcons:r})=>{var d,a;const s=l(Math.random().toString(36).slice(2)).current,{expandedInfo:u}=c(_),p=(null==u?void 0:u.rowId)===s,h=Array.isArray(null==o?void 0:o.children)?o.children.filter(e=>"element"===e.type).length:1,v=null!==(a=null===(d=null==o?void 0:o.properties)||void 0===d?void 0:d.style)&&void 0!==a?a:void 0;return i(H.Provider,{value:{rowId:s},children:[e("tr",{style:v?{cssText:v}:void 0,children:n}),p&&(null==u?void 0:u.aiReason)&&e("tr",{style:{width:"100%"},children:e("td",{colSpan:h||1,className:g.tableExpandedCell,children:e("div",{className:g.tableExpandedCellInner,children:e("div",{className:g.tableExpandedCellContent,children:e(A,{aiReason:u.aiReason,customIcons:r,customStyles:{aiReasoningContent:null==t?void 0:t.aiReasoningContent,aiReasoningAccordion:null==t?void 0:t.aiReasoningAccordion,aiReasoningMarkdown:null==t?void 0:t.aiReasoningMarkdown,aiReasoningPill:null==t?void 0:t.aiReasoningPill,webCitation:null==t?void 0:t.webCitation,stormeeCitation:null==t?void 0:t.stormeeCitation,waveformCitation:null==t?void 0:t.waveformCitation,imageCitation:null==t?void 0:t.imageCitation,fileCitation:null==t?void 0:t.fileCitation,appModCitation:null==t?void 0:t.appModCitation,rcaCitation:null==t?void 0:t.rcaCitation,readFileCitation:null==t?void 0:t.readFileCitation,loadingCitations:null==t?void 0:t.loadingCitations,chatCitation:null==t?void 0:t.chatCitation}})})})})})]})};const O=["del","ins"];function V(e){return function(e,n,i){const o=n.join("|");return e.replace(new RegExp(`<(${o})>([\\s\\S]*?)<\\/\\1>`,"gi"),(e,n,o)=>`<${n}>${i(o)}</${n}>`)}(e,O,e=>e.split(/(<[^>]+>)/g).map(e=>!e||/^<[^>]+>$/.test(e)?e:function(e){if(!e)return e;const n=[];return e.replace(/`([^`\n]+)`/g,(e,i)=>`@@CODE_SPAN_${n.push(i)-1}@@`).replace(/\*\*([\s\S]+?)\*\*/g,"<strong>$1</strong>").replace(/__([\s\S]+?)__/g,"<strong>$1</strong>").replace(/@@CODE_SPAN_(\d+)@@/g,(e,i)=>{var o;return`<code>${t=null!==(o=n[Number(i)])&&void 0!==o?o:"",t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}</code>`;var t})}(e)).join(""))}const q=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function z(e,n){const i=[],t=new Set(n.map(e=>e.toLowerCase())),l=e=>{var n,r;try{if(null==e||"boolean"==typeof e)return null;if("string"==typeof e||"number"==typeof e)return e;if(Array.isArray(e))return e.map(e=>l(e)).flat().filter(e=>null!=e);if(!o.isValidElement(e))return e;const d="string"==typeof e.type?e.type.toLowerCase():"";if(t.has(d))return i.push(e),null;if(q.has(d))return e;const a=null===(r=o.Children.map(null===(n=e.props)||void 0===n?void 0:n.children,l))||void 0===r?void 0:r.flat().filter(e=>null!=e);return a&&0!==a.length?o.cloneElement(e,void 0,a):null}catch(n){return console.error("splitNestedDiffNodes failed while processing node:",n),e}};try{return{cleanedChildren:l(e),extractedNodes:i}}catch(n){return console.error("splitNestedDiffNodes failed:",n),{cleanedChildren:e,extractedNodes:[]}}}const W=({message:t,noMarkdownContent:b,useMarkdown:I=!0,isParent:A,scenario:H,showUserStoryDiff:O=!1,aiReasoningsForBlock:q,isCitationLoadingDisplay:W=!1,className:G,highConfidenceIcon:Q,lowConfidenceIcon:J,customStyles:K,customIcons:X,contextVariant:Y,aiReasoningDiffView:Z,userStoryCitations:ee,artifactId:ne,isCraflow:ie,onCraAccept:oe,onCraReject:te,craFlowConfig:le,isDisplayHighlightControl:re=!1,showConfidenceScore:de=!0,CDNeededInChip:ae})=>{var se;const ce=l(null),{userStory:ue,inlineUpdateComponentConfig:pe,getAvgScoreForStory:ge,setUserStory:he,aiReasoning:ve,setAiReasoning:me,customIcons:Ce,searchQueryList:fe,searchQueryReasoningIdList:ye,currentHighlightIndex:we,segmentComponentConfig:Se,inlineManualComponentConfig:be,diffEditConfig:Ie}=S(),Re=null!=X?X:null==Ce?void 0:Ce.userStoryIcons;null==K||K.searchHighlight;const{search:$e,clear:xe}=h(ce),[Ne,ke]=r("1"),[Ae,je]=r(null),Ue=l(new Map),[Ee,Le]=r(new Set),Me=d((e,n)=>{je(e&&n?{rowId:e,aiReason:n}:null)},[]),Te=ne?ge(ne):0,[Pe,De]=r([]),_e=d(e=>{Le(n=>{const i=new Set(n);return i.has(e)?i.delete(e):i.add(e),i})},[]),He=e=>null==e?"":"string"==typeof e?e:"number"==typeof e?String(e):Array.isArray(e)?e.map(He).join(""):o.isValidElement(e)?He(e.props.children):"",Fe=e=>{let n=e;return n=n.replace(/<deleted>([\s\S]*?)<\/deleted>/gi,(e,n)=>`<deleted>${n.replace(/ai_reasoning\$(\d+)/g,(e,n)=>`ai_reasoning$${n}-legacy`)}</deleted>`),n=n.replace(/<generatedCode([^>]*)>([\s\S]*?)<\/generatedCode>/gi,(e,n,i)=>`\n\n<generatedCode${n} data-raw="${btoa(encodeURIComponent(i.trim()))}"></generatedCode>\n\n`),n=n.replace(/^(\s*[-*]|\s*\d+\.)\s*\n?\s*(<updated\b)/gm,"$1 $2"),n=n.replace(/(<segment\b([^>]*)>)([\s\S]*?)(<\/segment>)/gi,(e,n,i,o,t)=>{const l=o.match(/<table[\s\S]*?<\/table>/i);if(l){return`<segment${i} data-table="${btoa(encodeURIComponent(l[0]))}"></segment>`}return e}),n=n.replace(/<updatedsegment([^>]*)>([\s\S]*?)<\/updatedsegment>/gi,(e,n,i)=>{if(/<table[\s>]/i.test(i)){return`<updatedsegment${n} data-raw="${btoa(encodeURIComponent(i))}"></updatedsegment>`}return e}),n=n.replace(/<updated([^>]*)>([\s\S]*?)<\/updated>/gi,(e,i,o,t)=>{const l=n.substring(0,t),r=l.lastIndexOf("\n"),d=/^\s+[-*]\s/.test(l.substring(r+1))||/^\s+\d+\.\s/.test(l.substring(r+1)),a=/^\s*(\d+\.|\s*[-*])\s+$/.test(l.substring(r+1));if(d||a){let e=o;return e=e.replace(/(<deleted>)\s*\n?\s*[-*]\s+/gi,"$1\n"),e=e.replace(/(<changed>)\s*\n?\s*[-*]\s+/gi,"$1\n"),e=e.replace(/(<deleted>)\s*\n?\s*\d+\.\s+/gi,"$1\n"),e=e.replace(/(<changed>)\s*\n?\s*\d+\.\s+/gi,"$1\n"),`<updated${i}>${e}</updated>`}return e}),n=function(e){const n=/<updated[^>]*>[\s\S]*?<\/updated>/gi,i=[];let o;const t=new RegExp(n.source,n.flags);for(;null!==(o=t.exec(e));){const e=o[0],n=e.match(/<deleted>([\s\S]*?)<\/deleted>/i),t=e.match(/<changed>([\s\S]*?)<\/changed>/i),l=e=>(e.match(/^\s*\d+\.\s/gm)||[]).length;i.push({index:o.index,endIndex:o.index+o[0].length,deletedItemCount:l((null==n?void 0:n[1])||""),changedItemCount:l((null==t?void 0:t[1])||"")})}if(0===i.length)return e;let l=e;for(let e=i.length-1;e>=0;e--){const n=i[e],o=n.changedItemCount-n.deletedItemCount;if(0===o)continue;const t=l.substring(0,n.index).split("\n").reverse();let r=!1;for(const e of t){const n=e.trim();if(""!==n){/^\d+\.\s/.test(n)&&(r=!0);break}}if(!r)continue;const d=n.endIndex,a=e+1<i.length?i[e+1].index:l.length;let s=l.substring(d,a);s=s.replace(/^(\s*)(\d+)\.\s/gm,(e,n,i)=>`${n}${parseInt(i,10)+o}. `),l=l.substring(0,d)+s+l.substring(a)}return l}(n),n=function(e){let n=e.replace(/<deleted>([\s\S]*?)<\/deleted>/gi,(e,n)=>{const i=n.replace(/\n{2,}/g,"\n");return console.log("[normalizeCustomTags] collapseNewlines in <deleted>",{hadChange:i!==n}),`<deleted>${i}</deleted>`});return n=n.replace(/<changed>([\s\S]*?)<\/changed>/gi,(e,n)=>{const i=n.replace(/\n{2,}/g,"\n");return console.log("[normalizeCustomTags] collapseNewlines in <changed>",{hadChange:i!==n,preview:n.substring(0,120)}),`<changed>${i}</changed>`}),n}(n),n=V(n),n},Be=a(()=>t?Fe(t):t,[t]);s(()=>{De(q||ve)},[q,ve]);const Oe=a(()=>({span:({node:n,children:i,...o})=>{var t,l,r,d,a;const s=null!==(l=null===(t=null==n?void 0:n.properties)||void 0===t?void 0:t["highlight-id"])&&void 0!==l?l:null==o?void 0:o["highlight-id"],c="string"==typeof s&&Ee.has(s),u=null!==(d=null===(r=null==n?void 0:n.properties)||void 0===r?void 0:r["highlight-color"])&&void 0!==d?d:null==o?void 0:o["highlight-color"];return e("span",{style:{...null!==(a=null==K?void 0:K.span)&&void 0!==a?a:{},...c?{backgroundColor:u||"#fef08a"}:{}},children:i})},button:({node:i,children:o,...t})=>{var l,r,d,a,s,c;const u=null!==(r=null===(l=null==i?void 0:i.properties)||void 0===l?void 0:l.action)&&void 0!==r?r:null==t?void 0:t.action,p=null!==(a=null===(d=null==i?void 0:i.properties)||void 0===d?void 0:d["highlight-id"])&&void 0!==a?a:null==t?void 0:t["highlight-id"],g=null!==(c=null===(s=null==i?void 0:i.properties)||void 0===s?void 0:s["highlight-type"])&&void 0!==c?c:null==t?void 0:t["highlight-type"];return"highlight"===u?e(M,{highlightId:p,handleHighlightSpan:_e,icon:"web"===g?null==Re?void 0:Re.webCitationIcon:"doc"===g?null==Re?void 0:Re.fileCitationIcon:e(n,{}),customStyles:"web"===g?null==K?void 0:K.webButton:"doc"===g?null==K?void 0:K.docButton:{}}):null},upt:({node:i,children:o,...t})=>{var l,r;const d=null==t?void 0:t.id,a=d?null===(r=null===(l=d.split("$"))||void 0===l?void 0:l[1])||void 0===r?void 0:r.replaceAll("@","<").replaceAll("#",">"):null,s=ve.find(e=>e.id.toString()===a);return s?e(n,{children:e(j,{aiReason:s,customStyles:null==K?void 0:K.inlineUpdatedComponent,handleClickCognitiveDecision:null==pe?void 0:pe.handleClickCognitiveDecision,handleClickUpdatedPill:null==pe?void 0:pe.handleClickUpdatedPill,handleClickOutputValue:null==pe?void 0:pe.handleClickOutputValue,customIcons:null==pe?void 0:pe.customIcons,CDNeededInChip:ae,children:o||e(n,{})})}):o||e(n,{})},del:({node:o,children:t,...l})=>{var r;const{cleanedChildren:d,extractedNodes:a}=z(t,["ins"]);return i(n,{children:[e("span",{className:g.deleted,style:null!==(r=null==K?void 0:K.deleted)&&void 0!==r?r:{},...l,onClick:()=>{l.onclick&&l.onclick()},children:d}),a]})},ins:({children:o,...t})=>{var l;const{cleanedChildren:r,extractedNodes:d}=z(o,["del"]);return i(n,{children:[e("span",{className:g.inserted,style:null!==(l=null==K?void 0:K.inserted)&&void 0!==l?l:{},...t,onClick:()=>{t.onclick&&t.onclick()},children:r}),d]})},preserved:({children:n,...i})=>e("span",{className:g.preserved,style:null==K?void 0:K.preserved,...i,children:n}),manual:({children:i,...o})=>{var t;const l=null===(t=null==o?void 0:o.id)||void 0===t?void 0:t.replaceAll("@","<").replaceAll("#",">"),r=ve.find(e=>e.id.toString()===l);return r?e(L,{aiReason:r,handleClick:null==be?void 0:be.handleClick,children:i}):i||e(n,{})},invisible:({children:i,...o})=>e(n,{}),h1:({node:n,...i})=>e("h1",{className:g.heading1,style:null==K?void 0:K.heading1,children:i.children}),h2:({node:n,...i})=>e("h2",{className:g.heading2,style:null==K?void 0:K.heading2,children:i.children}),h3:({node:n,...i})=>e("h3",{className:g.heading3,style:null==K?void 0:K.heading3,children:i.children}),b:({node:n,...i})=>e("b",{className:g.bold,style:null==K?void 0:K.bold,children:null==i?void 0:i.children}),p:({node:n,...i})=>e("p",{...i,className:g.paragraph,style:null==K?void 0:K.paragraph,children:i.children}),updated:({node:n,...i})=>e(f,{...i,showUserStoryDiff:O,currentUpdatedTagId:Ne,setCurrentUpdatedTagId:ke,userStory:ue,setUserStory:he,setAiReasoning:me,node:n,isCraflow:ie,onCraAccept:oe,onCraReject:te,diffEditConfig:Ie,customStyles:null==K?void 0:K.updatedContent,craFlowConfig:le}),ol:({node:n,...i})=>{var o,t,l;const r=null!==(l=null!==(t=null===(o=null==n?void 0:n.properties)||void 0===o?void 0:o.start)&&void 0!==t?t:null==i?void 0:i.start)&&void 0!==l?l:void 0;return e("ol",{className:g.orderedList,style:null==K?void 0:K.olist,...r?{start:Number(r)}:{},children:null==i?void 0:i.children})},ul:({node:n,...i})=>e("ul",{className:g.unorderedList,style:null==K?void 0:K.ulist,children:null==i?void 0:i.children}),table:({children:n})=>e("div",{className:g.tableWrapper,children:e("table",{className:g.table,style:null==K?void 0:K.table,children:n})}),tr:({node:n,children:i})=>e(B,{node:n,children:i,customStyles:K}),td:({node:n,children:i})=>{var o;const{style:t,...l}=null!==(o=null==n?void 0:n.properties)&&void 0!==o?o:{};return e(D.Provider,{value:!0,children:e("td",{...l,style:t?{cssText:t}:void 0,children:i})})},th:({node:n,children:i})=>{var o;const{style:t,...l}=null!==(o=null==n?void 0:n.properties)&&void 0!==o?o:{};return e(D.Provider,{value:!0,children:e("th",{...l,style:t?{cssText:t}:void 0,children:i})})},recommendation:({node:n,...i})=>{var o;const t=`The AI has selected this content based on: ${(null===(o=null==i?void 0:i.children)||void 0===o?void 0:o[0])||""}`;return e(N,{...i,customStyles:null==K?void 0:K.recommendationBlock,label:t})},a:({inline:n,children:i,node:o,...t})=>{var l,r,d;const a=c(D)||"true"==(null==t?void 0:t.table),s=`${null==t?void 0:t.href}`,u=null===(l=s.split("$"))||void 0===l?void 0:l[0],p=null===(r=s.split("$"))||void 0===r?void 0:r[1];if("ai_reasoning"===u){const n=(null!==(d=O?Z:ve)&&void 0!==d?d:[]).find(e=>e.id.toString()===decodeURIComponent(p)),o=ye.includes(p);if(n){if(a)return e(F,{aiReason:n,customStyle:null==K?void 0:K.tableAiReasoning,customIcons:Re,isHighConfidence:n.relevance_score>=$});const t=He(i),l="source"!==t.trim().toLowerCase();return e(R,{aiReason:n,isSourceHasHighlight:o,inlineLabel:t,isInlineCitation:l,customIcons:Re,customStyles:{aiReasoningContent:null==K?void 0:K.aiReasoningContent,aiReasoningAccordion:null==K?void 0:K.aiReasoningAccordion,aiReasoningMarkdown:null==K?void 0:K.aiReasoningMarkdown,aiReasoningPill:null==K?void 0:K.aiReasoningPill,webCitation:null==K?void 0:K.webCitation,stormeeCitation:null==K?void 0:K.stormeeCitation,waveformCitation:null==K?void 0:K.waveformCitation,imageCitation:null==K?void 0:K.imageCitation,fileCitation:null==K?void 0:K.fileCitation,appModCitation:null==K?void 0:K.appModCitation,rcaCitation:null==K?void 0:K.rcaCitation,readFileCitation:null==K?void 0:K.readFileCitation,loadingCitations:null==K?void 0:K.loadingCitations,chatCitation:null==K?void 0:K.chatCitation,bigEnoughCitation:null==K?void 0:K.bigEnoughCitation}})}}return null},code:({inline:n,children:i,className:o,node:t,...l})=>/language-(\w+)/.exec(o||"")||(null==o?void 0:o.includes("language-"))?e("div",{children:e("code",{className:g.blockCode,style:null==K?void 0:K.code,children:i})}):e("code",{className:g.inlineCode,style:null==K?void 0:K.code,children:i}),learned:({children:n})=>e(m,{title:n,placement:"top",children:e(v,{size:16,className:g.learned})}),generatedcode:({node:n,...i})=>{const o=(null==i?void 0:i.language)||"python",t=(e=>{let n="";try{if(e["data-raw"])n=decodeURIComponent(atob(e["data-raw"]));else{const i=e=>{var n;return"string"==typeof e?e:Array.isArray(e)?e.map(i).join(""):(null===(n=null==e?void 0:e.props)||void 0===n?void 0:n.children)?i(e.props.children):""};n=i(e.children)}}catch(i){console.error("Error decoding generated code:",i),n=String(e.children)}return n})(i);return e(y,{title:"Generated Code",code:t,language:o,customStyles:{pill:null==K?void 0:K.generatedCodePill,content:null==K?void 0:K.generatedCodeContent}})},updatedsegment:({node:n,children:i,...o})=>{var t,l,r,d;const a=`${null===(t=n.position)||void 0===t?void 0:t.start.line}-${null===(l=n.position)||void 0===l?void 0:l.start.column}-${null===(r=n.position)||void 0===r?void 0:r.end.line}-${null===(d=n.position)||void 0===d?void 0:d.end.column}`,s=(e=>{if(!e["data-raw"])return null;try{return decodeURIComponent(atob(e["data-raw"]))}catch(e){return console.error("Error decoding segment raw content:",e),null}})(o),c=e("div",s?{dangerouslySetInnerHTML:{__html:C.sanitize(s)}}:{children:i});return e(U,{id:a,node:n,children:c,props:o,segmentComponentConfig:Se,customStyles:K,customIcons:X,extractText:He,isUpdatedSegment:!0})},segment:({node:n,children:i,...o})=>{var t,l,r,d;const a=`${null===(t=n.position)||void 0===t?void 0:t.start.line}-${null===(l=n.position)||void 0===l?void 0:l.start.column}-${null===(r=n.position)||void 0===r?void 0:r.end.line}-${null===(d=n.position)||void 0===d?void 0:d.end.column}`;return e(U,{id:a,node:n,children:i,props:o,segmentComponentConfig:Se,customStyles:K,customIcons:X,extractText:He})}}),[Pe,le,ve,ee,Ne,O,t,X,fe,ye,K,Se,Ee,_e]),Ve=a(()=>{let e=T(Be,["manual","upt"]);return["del","ins","preserved","manual","upt"].forEach(n=>{e=P(e,n)}),e},[Be]);return s(()=>{if(!ce.current)return;if(!fe.length)return void xe();let e;if(0===ye.length||re)requestAnimationFrame(()=>{$e([fe[we].replace(/\*/g,"")])});else{const n=ce.current,i=new MutationObserver(()=>{clearTimeout(e),e=setTimeout(()=>{i.disconnect(),requestAnimationFrame(()=>{$e([fe[we].replace(/\*/g,"")])})},50)});i.observe(n,{childList:!0,subtree:!0})}return()=>{clearTimeout(e)}},[fe,ye,we,re]),e(_.Provider,{value:{expandedInfo:Ae,setExpanded:Me,reasonToRow:Ue},children:i("div",{ref:ce,className:`${g.container} ${"approving"!==H?g.wrapper:""} ${G||""}`,style:null==K?void 0:K.container,children:[I?e(E,{children:e(u,{components:Oe,rehypePlugins:[p],children:Ve})}):b,Te>0&&de&&e("div",{className:g.confidenceScoreContainer,style:null==K?void 0:K.confidenceScoreContainer,children:i("span",{className:g.confidenceScore,style:null==K?void 0:K.confidenceScore,children:[e(x,{size:14,color:(null==K?void 0:K.confidenceScoreIconColor)||"#166534"}),Te,"%"]})}),W&&e("div",{className:g.citationLoader,style:null==K?void 0:K.citationLoaderContainer,children:e(w,{customStyles:{container:null==K?void 0:K.citationLoadingContainer,icon:null==K?void 0:K.citationLoadingIcon,text:null==K?void 0:K.citationLoadingText}})}),A&&e("div",{style:{...null===(se=null==K?void 0:K.attachedContext)||void 0===se?void 0:se.wrapper},className:"flex mt-5",children:e(k,{customStyles:null==K?void 0:K.attachedContext,variant:Y})})]})})};export{W as default,z as splitNestedDiffNodes};
|
|
2
2
|
//# sourceMappingURL=UserStoryWithCitation.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as l}from"react/jsx-runtime";import n from"./InlineManualComponent.module.css.js";function
|
|
1
|
+
import{jsx as l}from"react/jsx-runtime";import n from"./InlineManualComponent.module.css.js";function a(a){var i,o,e,t;return l("span",{className:n[`manual-${null===(i=a.aiReason.redlining_details)||void 0===i?void 0:i.status}`],"data-id":null===(t=null===(e=null===(o=null==a?void 0:a.aiReason)||void 0===o?void 0:o.id)||void 0===e?void 0:e.toString)||void 0===t?void 0:t.call(e),onClick:l=>{var n;l.stopPropagation(),l.preventDefault(),null===(n=a.handleClick)||void 0===n||n.call(a,l.currentTarget,a.aiReason)},children:a.children})}export{a as default};
|
|
2
2
|
//# sourceMappingURL=InlineManualComponent.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as l,jsxs as e,Fragment as n}from"react/jsx-runtime";import{Divider as o,CircularProgress as i}from"@mui/material";import{hexToOpacity as t}from"../../../utils/css.utils.js";import r from"./InlineUpdatedComponent.module.css.js";import d from"../../../icons/CognitiveDecision.js";import{Check as a,X as s,Undo2 as u,ChevronDown as c}from"lucide-react";import{useRef as v,useState as p,useCallback as m,useLayoutEffect as g}from"react";const f=({aiReason:f,children:h,customStyles:C,handleClickCognitiveDecision:y,handleClickUpdatedPill:b,handleClickOutputValue:w,customIcons:_,CDNeededInChip:k=!0})=>{var N,D,P,S,$,I,j,x,z,A,L,R,T,W,E,M,O,U,B,F,H,q,V;const G=v(null),J=v(null),[K,Q]=p(null),X=m(()=>{var l;const e=J.current,n=(null===(l=G.current)||void 0===l?void 0:l.offsetParent)||(null==e?void 0:e.offsetParent);if(!(e&&n instanceof HTMLElement))return;const o=e.getBoundingClientRect(),i=n.getBoundingClientRect(),t=o.top-i.top+o.height/2;Q(l=>null!==l&&Math.abs(l-t)<.5?l:t)},[]);g(()=>{X()}),g(()=>{var l,e;if("undefined"==typeof window)return;const n=window.requestAnimationFrame(X);window.addEventListener("resize",X);const o="undefined"!=typeof ResizeObserver?new ResizeObserver(X):null;J.current&&(null==o||o.observe(J.current));const i=(null===(l=G.current)||void 0===l?void 0:l.offsetParent)||(null===(e=J.current)||void 0===e?void 0:e.offsetParent);return i instanceof HTMLElement&&(null==o||o.observe(i)),()=>{window.cancelAnimationFrame(n),window.removeEventListener("resize",X),null==o||o.disconnect()}},[X]);const Y="pending"!==(null===(N=f.redlining_details)||void 0===N?void 0:N.status)?"#303030":null===(S=null===(P=null===(D=f.redlining_details)||void 0===D?void 0:D.evaluation_outputs)||void 0===P?void 0:P.metadata)||void 0===S?void 0:S.label_color,Z={color:Y||"#000000",background:t(Y||"#000000",25),border:`1px solid ${t(Y||"#000000",75)}`},ll=Y||"#000000",el=t(Y||"#000000",25),nl={background:t(Y||"#000000",75),...null==C?void 0:C.dividerStyle};let ol=null;const il=null===($=f.redlining_details)||void 0===$?void 0:$.status;"accepted"===il?ol=null!==(I=null==_?void 0:_.accepted)&&void 0!==I?I:l(a,{color:"#16A34A"}):"rejected"===il?ol=null!==(j=null==_?void 0:_.rejected)&&void 0!==j?j:l(s,{color:"#DC2626"}):"reverted"===il&&(ol=null!==(x=null==_?void 0:_.reverted)&&void 0!==x?x:l(u,{color:"#475569"}));const tl=null===K?{}:{"--inline-update-anchor-top":`${K}px`},rl=null===K?"":` ${r.anchorAligned}`;return e("span",{className:r.inlineUpdatedWrapper,children:[ol&&l("span",{className:`${r.resolvedStatus}${rl}`,style:{...tl,...null==C?void 0:C.resolvedIcon},children:ol}),l("span",{ref:G,"data-id":f.id.toString(),onClick:l=>{l.stopPropagation(),null==b||b(l.currentTarget,f)},className:`${r.pillWrapper}${rl}`,style:{...tl,...null==C?void 0:C.pillStyleWrapper},children:e("span",{className:r.pillComponent,style:{...Z,...null===(z=null==C?void 0:C.pillComponent)||void 0===z?void 0:z.commonStyle},children:[l("span",{children:(null===(R=null===(L=null===(A=f.redlining_details)||void 0===A?void 0:A.evaluation_outputs)||void 0===L?void 0:L.metadata)||void 0===R?void 0:R.label_text)||""}),l(o,{className:r.dividerStyle,style:nl}),l("span",{className:r["output-container"],onClick:l=>{w&&(l.stopPropagation(),null==w||w(l.currentTarget,f))},children:f.resolving?l(i,{size:(null===(T=null==C?void 0:C.loader)||void 0===T?void 0:T.size)||18,"aria-label":"Loading…",sx:{color:(null===(W=null==C?void 0:C.loader)||void 0===W?void 0:W.color)||Y}}):"pending"!==(null===(E=f.redlining_details)||void 0===E?void 0:E.status)?ol:null===(O=null===(M=null==f?void 0:f.redlining_details)||void 0===M?void 0:M.evaluation_outputs)||void 0===O?void 0:O.output_value}),k&&e(n,{children:[l(o,{className:r.dividerStyle,style:nl}),l("span",{onClick:l=>{l.stopPropagation(),null==y||y(l.currentTarget,f)},className:r.cognitiveDecisionWrapper,style:null===(U=null==C?void 0:C.cognitiveDecisionIcon)||void 0===U?void 0:U.wrapper,children:l(d,{color:(null===(B=null==C?void 0:C.cognitiveDecisionIcon)||void 0===B?void 0:B.color)||ll,backgroundColor:(null===(F=null==C?void 0:C.cognitiveDecisionIcon)||void 0===F?void 0:F.backgroundColor)||el})}),l("span",{className:r.chevronWrapper,style:null===(H=null==C?void 0:C.Chevron)||void 0===H?void 0:H.wrapper,children:l(c,{color:(null===(q=null==C?void 0:C.Chevron)||void 0===q?void 0:q.color)||Y})})]})]})}),l("span",{ref:J,className:r[`upt-${null===(V=f.redlining_details)||void 0===V?void 0:V.status}`],onClick:l=>{l.preventDefault(),l.stopPropagation(),G.current&&(null==b||b(G.current,f))},children:h})]})};export{f as default};
|
|
2
2
|
//# sourceMappingURL=InlineUpdatedComponent.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e){try{return e
|
|
1
|
+
function e(e){try{return e}catch(e){console.error("Error in formatMarkdown",e)}}function r(e){return e.includes("Acceptance Criteria")?e=null==(e=null==(e=null==(e=null==e?void 0:e.replace(/\\n/g,"\n"))?void 0:e.replace(/(\*\*.+?\*\*)\s*:/g,"\n$1:\n"))?void 0:e.replace(/(?<!\d)(\d+(?:\.\d+)+)\./g,(e,r)=>{const n=r.split(".");return`${" ".repeat(n.length-1)}${r}.`}))?void 0:e.replace(/([^\n])\n(?![\n\*#])/g,"$1<br>\n"):e}const n=e=>{if(!e)return"";e=(e=(e=(e=(e=e.replace(/%&&%[\s\S]*?%&&%/g,"")).replace(/<!--[\s\S]*?-->/g,"")).replace(/<crredirection[^>]*>[\s\S]*?<\/crredirection>/gi,"")).replace(/<answerExample[^>]*>[\s\S]*?<\/answerExample>/gi,"")).replace(/<a\s+data-cognitive-reasoning[^>]*>[\s\S]*?<\/a>/gi,"");return["b","strong","i","em","u","ol","ul","li","p","div","span","h1","h2","h3","h4","h5","h6","highlight","br","hr"].forEach(r=>{const n=new RegExp(`</?${r}[^>]*>`,"gi");e=e.replace(n,"")}),e=(e=(e=(e=(e=e.replace("ð","")).replace(/\*\*/g,"")).replace(/\n/g," ")).replace(/\s+/g," ")).trim()},a=e=>{const r=(new DOMParser).parseFromString(e,"text/html");return Array.from(r.querySelectorAll('a[href^="ai_reasoning$"]')).map(e=>e.getAttribute("href").replace("ai_reasoning$",""))},t=e=>{const r=(new DOMParser).parseFromString(e,"text/html");return r.querySelectorAll('a[href^="ai_reasoning$"]').forEach(e=>{e.remove()}),r.body.innerHTML.trim()};export{a as extractAllAiReasoningIds,e as formatMarkdown,r as indentMarkdown,t as stripAiReasoningAnchors,n as stripHtmlAndMetadata};
|
|
2
2
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CognitiveCompareTest.d.ts","sourceRoot":"","sources":["../../../src/CognitiveCompareTest.tsx"],"names":[],"mappings":"AAOA,QAAA,MAAM,oBAAoB,+
|
|
1
|
+
{"version":3,"file":"CognitiveCompareTest.d.ts","sourceRoot":"","sources":["../../../src/CognitiveCompareTest.tsx"],"names":[],"mappings":"AAOA,QAAA,MAAM,oBAAoB,+CA6MzB,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RedlineEditorTest.d.ts","sourceRoot":"","sources":["../../../src/RedlineEditorTest.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RedlineEditorTest.d.ts","sourceRoot":"","sources":["../../../src/RedlineEditorTest.tsx"],"names":[],"mappings":"AAyBA,iBAAS,iBAAiB,4CA4jCzB;AAED,eAAe,iBAAiB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequirementAiTest.d.ts","sourceRoot":"","sources":["../../../src/RequirementAiTest.tsx"],"names":[],"mappings":"AA8BA,OAAO,EAA2B,cAAc,EAAE,aAAa,EAAE,MAAM,+EAA+E,CAAC;
|
|
1
|
+
{"version":3,"file":"RequirementAiTest.d.ts","sourceRoot":"","sources":["../../../src/RequirementAiTest.tsx"],"names":[],"mappings":"AA8BA,OAAO,EAA2B,cAAc,EAAE,aAAa,EAAE,MAAM,+EAA+E,CAAC;AAWvJ,QAAA,MAAM,iBAAiB,+CAstFtB,CAAC;AAiVF,eAAO,MAAM,iBAAiB,EAAE,cAAc,EAoH7C,CAAC;AAGF,eAAO,MAAM,gBAAgB,EAAE,aAAa,EAoV3C,CAAC;AAGF,eAAO,MAAM,mBAAmB,YACrB,cAAc,EAAE,GAAG,aAAa,EAAE;;;;;CA0B5C,CAAC;AAGF,eAAe,iBAAiB,CAAC"}
|