import{__assign as e,__spreadArray as r}from"tslib";import{jsxs as n,jsx as o}from"react/jsx-runtime";import{useState as i}from"react";import{Paper as t,Box as l,Typography as a,Tooltip as c,Accordion as s,AccordionSummary as d,AccordionDetails as f}from"@mui/material";import{Info as u,ChevronDown as m,Lightbulb as p}from"lucide-react";import x from"../../../CommonComponents/GradientSparkleIcon.js";var h=function(r){var i=function(e){return Math.round(Math.min(e,100))}(r.score),t={bg:"#f2f0f2",text:"#343f52"};return o(c,e({title:"AI Confidence Score",placement:"top",arrow:!0},{children:n(l,e({sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1,mr:1,py:.5,borderRadius:"16px",backgroundColor:t.bg,color:t.text,fontSize:"0.8rem",fontWeight:600,fontFamily:"'Inter', sans-serif"}},{children:[o(x,{color:t.text}),n(a,e({sx:{fontSize:"0.8rem",fontWeight:600,fontFamily:"'Inter', sans-serif"}},{children:[i,"%"]}))]}))}))},g=function(x){var g=x.similarRules,b=x.showUpdateWarning,F=x.className,C=x.detectionType,y=i(g.map(function(e,r){return r})),w=y[0],R=y[1],S="Similar Rules Detected";"conflicting"===C?S="Conflicting Rules Detected":"both"===C&&(S="Similar & Conflicting Rules Detected");var B=i({}),v=B[0],I=B[1];if(!g||0===g.length)return null;var W=function(e){return String.fromCharCode(65+e)};return n(t,e({elevation:0,className:F,sx:{width:"100%",maxWidth:"1050px",margin:"20px auto",backgroundColor:"#FFFFFF",border:"1px solid #b3b3b3ff",padding:3,borderRadius:"12px",fontFamily:"'Inter', sans-serif"}},{children:[n(l,e({sx:{display:"flex",alignItems:"center",mb:2}},{children:[o(a,e({sx:{fontSize:"1.1rem",fontWeight:700,color:"#B91C1C"}},{children:S})),o(c,e({slotProps:{tooltip:{sx:{fontSize:"0.9rem"}}},title:"The rules you've defined are similar to existing rules in other agents. Please review them to avoid redundancy.",arrow:!0},{children:o(u,{size:16,color:"#B91C1C",style:{marginLeft:"8px",cursor:"pointer"}})}))]})),o(l,e({sx:{maxHeight:400,overflowY:"auto",pr:1.5}},{children:g.map(function(i,t){var c=w.includes(t),u=i.wtaRules&&i.wtaRules.length>0,x=i.wntaRules&&i.wntaRules.length>0,g="conflicting"===i.type?"conflicting":"similar";return n(s,e({expanded:c,onChange:function(){return function(e){R(function(n){return n.includes(e)?n.filter(function(r){return r!==e}):r(r([],n,!0),[e],!1)})}(t)},disableGutters:!0,sx:{mb:1.5,border:"1px solid #FCA5A5",borderRadius:"3px","&:before":{display:"none"}}},{children:[o(d,e({expandIcon:o(m,{size:20,color:"#991B1B"}),sx:{backgroundColor:"#FEF2F2",borderBottom:c?"1px solid #FCA5A5":"none"}},{children:n(l,e({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"}},{children:[o(a,e({sx:{color:"#991B1B",fontWeight:600,fontSize:"0.95rem"}},{children:"".concat(W(t),". ").concat(i.agentName," has a ").concat(g," rule")})),o(h,{score:i.confidenceScore})]}))})),n(f,e({sx:{px:2,pb:2,backgroundColor:"#FFF"}},{children:[n(l,e({sx:{display:"flex",flexDirection:{xs:"column",sm:u&&x?"row":"column"},gap:2,mb:2}},{children:[u&&n(l,e({sx:{flex:1,border:"1px solid #E5E7EB",borderRadius:2,p:2,backgroundColor:"#F9FAFB"}},{children:[o(a,e({sx:{fontWeight:600,mb:1,color:"#374151"}},{children:"When to Apply"})),o(a,e({sx:{whiteSpace:"pre-wrap",color:"#4B5563"}},{children:i.wtaRules.map(function(e,r){return"".concat(r+1,". ").concat(e)}).join("\n")}))]})),x&&n(l,e({sx:{flex:1,border:"1px solid #E5E7EB",borderRadius:2,p:2,backgroundColor:"#F9FAFB"}},{children:[o(a,e({sx:{fontWeight:600,mb:1,color:"#374151"}},{children:"When NOT to Apply"})),o(a,e({sx:{whiteSpace:"pre-wrap",color:"#4B5563"}},{children:i.wntaRules.map(function(e,r){return"".concat(r+1,". ").concat(e)}).join("\n")}))]}))]})),n(s,e({expanded:v[t]||!1,onChange:function(){return function(r){I(function(n){var o;return e(e({},n),((o={})[r]=!n[r],o))})}(t)},disableGutters:!0,elevation:0,sx:{border:"1px solid #e5e7eb",borderRadius:"8px",overflow:"hidden",mt:1,"&:before":{display:"none"}}},{children:[o(d,e({expandIcon:o(m,{size:16,color:"#6b7280"}),sx:{backgroundColor:"#f2f2f3ff",minHeight:"auto","&.Mui-expanded":{borderBottom:"1px solid #e5e7eb",minHeight:"auto"},"& .MuiAccordionSummary-content":{margin:"10px 0px"}}},{children:n(a,e({sx:{fontSize:"0.9rem",fontWeight:600,color:"#4b5563",fontFamily:"'Inter', sans-serif",display:"flex",alignItems:"center",gap:1}},{children:[o(p,{size:16})," Reason for ","similar"===g?"Similarity":"Conflict","?"]}))})),o(f,e({sx:{p:2,backgroundColor:"#f9fafb"}},{children:o(a,e({sx:{fontSize:"0.9rem",color:"#374151",fontFamily:"'Inter', sans-serif",lineHeight:1.6}},{children:i.reason}))}))]}))]}))]}),t)})})),b&&o(l,e({sx:{mt:3,p:1.5,borderRadius:"8px",backgroundColor:"#FFFBEB",border:"1px solid #FCD34D"}},{children:n(a,e({sx:{color:"#B45309",fontSize:"0.9rem",fontWeight:500,fontFamily:"'Inter', sans-serif"}},{children:[o("strong",{children:"Warning:"})," Please update the current rules since there already exists a similar rule."]}))}))]}))};export{g as default};
//# sourceMappingURL=SimilarConflictingCard.js.map
