1try{let e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ef242a36-8b18-49f6-81d5-9d847c33def6",e._sentryDebugIdIdentifier="sentry-dbid-ef242a36-8b18-49f6-81d5-9d847c33def6")}catch(e){}"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6827],{1940:(e,t,a)=>{a.d(t,{A:()=>u});var s=a(95155),r=a(12115),n=a(37911),l=a(20363),i=a(70747),o=a(4686),d=a(87020),c=a(31376);function u(e){let{open:t,setOpen:a,offenseIds:u=[],onSuccess:m,requestedTenant:f}=e,[p,v]=r.useState(""),[g,x]=r.useState(""),[y,h]=r.useState(""),b=async()=>{if(!g)return void c.toast.error("Please select a disposition");try{var e,t,s,r,n;let a=Array.from(new Set((Array.isArray(u)?u:[]).map(e=>String(e||"").trim()).filter(Boolean)));if(0===a.length)return void c.toast.error("No offense selected");let l=Array.isArray(f)?Array.from(new Set(f.filter(Boolean).map(String))):[],i=await (0,d.Ip)(a,g,l),o=null!=(s=null==i||null==(e=i.data)?void 0:e.successCount)?s:(null==i?void 0:i.success)?a.length:0,p=null!=(r=null==i||null==(t=i.data)?void 0:t.failedCount)?r:(null==i?void 0:i.success)?0:a.length;if(o>0){c.toast.success(p>0?"Closed ".concat(o," offense(s). ").concat(p," failed."):1===o?"Offense closed successfully":"Closed ".concat(o," offense(s)."));let e=((null==i||null==(n=i.data)?void 0:n.results)||[]).find(e=>!e.success);(null==e?void 0:e.message)&&c.toast.error(e.message),null==m||m()}else c.toast.error((null==i?void 0:i.message)||"Failed to close offense")}catch(e){c.toast.error((null==e?void 0:e.message)||"Failed to close offense")}finally{a(!1)}};return(0,s.jsx)(n.a,{heading:"Close Offense",open:t,onOpenChange:a,className:"max-w-5xl min-w-[300px]","data-sentry-element":"Modal","data-sentry-component":"CloseModal","data-sentry-source-file":"CloseModal.tsx",children:(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{className:"flex flex-col space-y-3",children:[(0,s.jsx)(l.J,{"data-sentry-element":"Label","data-sentry-source-file":"CloseModal.tsx",children:" Disposition "}),(0,s.jsx)(o.z,{value:g,onValueChange:e=>x(e),className:"ml-4","data-sentry-element":"RadioGroup","data-sentry-source-file":"CloseModal.tsx",children:[{id:1,is_deleted:!1,is_reserved:!1,text:"True-Positive"},{id:2,is_deleted:!1,is_reserved:!1,text:"True-Negative"},{id:3,is_deleted:!1,is_reserved:!1,text:"False-Positive"},{id:4,is_deleted:!1,is_reserved:!1,text:"False-Negative"}].map((e,t)=>(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(o.C,{value:e.text,id:"d".concat(t+2)}),(0,s.jsx)(l.J,{htmlFor:"d".concat(t+2),children:e.text})]},e.id))})]}),(0,s.jsx)("div",{className:"flex justify-end",children:(0,s.jsxs)(i.$,{onClick:()=>{b(),h(""),v("")},"data-sentry-element":"Button","data-sentry-source-file":"CloseModal.tsx",children:["Close"," "]})})]})})}},4686:(e,t,a)=>{a.d(t,{C:()=>o,z:()=>i});var s=a(95155);a(12115);var r=a(86033),n=a(94569),l=a(40980);function i(e){let{className:t,...a}=e;return(0,s.jsx)(r.bL,{"data-slot":"radio-group",className:(0,l.cn)("grid gap-3",t),...a,"data-sentry-element":"RadioGroupPrimitive.Root","data-sentry-component":"RadioGroup","data-sentry-source-file":"radio-group.tsx"})}function o(e){let{className:t,...a}=e;return(0,s.jsx)(r.q7,{"data-slot":"radio-group-item",className:(0,l.cn)("border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...a,"data-sentry-element":"RadioGroupPrimitive.Item","data-sentry-component":"RadioGroupItem","data-sentry-source-file":"radio-group.tsx",children:(0,s.jsx)(r.C1,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center","data-sentry-element":"RadioGroupPrimitive.Indicator","data-sentry-source-file":"radio-group.tsx",children:(0,s.jsx)(n.A,{className:"fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2","data-sentry-element":"CircleIcon","data-sentry-source-file":"radio-group.tsx"})})})}},6815:(e,t,a)=>{a.d(t,{A:()=>u});var s=a(95155),r=a(12115),n=a(37911),l=a(20363),i=a(12877),o=a(70747),d=a(87020),c=a(31376);function u(e){let{open:t,setOpen:a,offenseIds:u=[],requestedTenant:m,onSuccess:f}=e,[p,v]=r.useState(""),[g,x]=r.useState(!1);r.useEffect(()=>{t||(v(""),x(!1))},[t]);let y=async()=>{let e=p.trim();if(!e)return void c.toast.error("Please enter the case reference ID");let t=Array.isArray(u)?u.filter(Boolean):[];if(0===t.length)return void c.toast.error("Please select at least one offense");let s=Array.isArray(m)?Array.from(new Set(m.filter(Boolean).map(String))):[];x(!0);try{var r,n,l,i;let o=await (0,d.VN)(t,e,s),u=null!=(n=null==o||null==(r=o.data)?void 0:r.linkedCount)?n:0;if((null==o?void 0:o.success)&&u>0){c.toast.success(o.message||"Linked ".concat(u," offense(s) to the case."));let e=((null==(l=o.data)?void 0:l.results)||[]).filter(e=>!e.success);e.length>0&&(null==(i=e[0])?void 0:i.message)&&c.toast.error(e[0].message),a(!1),null==f||f();return}c.toast.error((null==o?void 0:o.message)||"Failed to link offense(s) to the case")}catch(e){c.toast.error((null==e?void 0:e.message)||"Failed to link offense(s) to the case")}finally{x(!1)}}
1,h=(u||[]).filter(Boolean).length;return(0,s.jsx)(n.a,{heading:"Link to Case",open:t,onOpenChange:a,className:"max-w-xl min-w-[300px]","data-sentry-element":"Modal","data-sentry-component":"LinkToCaseModal","data-sentry-source-file":"LinkToCaseModal.tsx",children:(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(l.J,{htmlFor:"case-reference-id","data-sentry-element":"Label","data-sentry-source-file":"LinkToCaseModal.tsx",children:"Case Reference ID"}),(0,s.jsx)(i.p,{id:"case-reference-id",autoFocus:!0,placeholder:"e.g. KEC-13",value:p,onChange:e=>v(e.target.value),onKeyDown:e=>{"Enter"!==e.key||g||y()},"data-sentry-element":"Input","data-sentry-source-file":"LinkToCaseModal.tsx"}),(0,s.jsx)("p",{className:"text-muted-foreground text-xs",children:1===h?"The selected offense will be linked to this case and marked as Cased.":"".concat(h," selected offenses will be linked to this case and marked as Cased.")})]}),(0,s.jsx)("div",{className:"flex justify-end",children:(0,s.jsx)(o.$,{onClick:()=>void y(),disabled:g,"data-sentry-element":"Button","data-sentry-source-file":"LinkToCaseModal.tsx",children:g?"Linking...":"Link"})})]})})}},15915:(e,t,a)=>{a.d(t,{Gy:()=>l,HL:()=>o,S1:()=>i,rX:()=>n});var s=a(85218),r=a(34686);let n=async function(){var e,t,a,n;let l=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;try{let a=Object.fromEntries(Object.entries(l).filter(e=>{let[,t]=e;return null!=t&&("string"!=typeof t||""!==t.trim())&&(Array.isArray(t)?t.length>0:"object"!=typeof t||Object.keys(t).length>0)})),n={...i},{user:o,fieldSearch:d,requestedTenant:c,...u}=i,m=null!=c?Array.isArray(c)?c:[c]:o?(0,r.jN)(o):[];if(n.fieldSearch){let e={...n.fieldSearch};Array.isArray(e.filters)&&(e.filters=e.filters.filter(e=>e&&"string"==typeof e.fieldName&&""!==e.fieldName.trim()&&Array.isArray(e.value)&&e.value.length>0&&"string"==typeof e.operator&&""!==e.operator.trim()),e.filters.length||delete e.filters),e.filters||e.logicalOperator?n.fieldSearch=e:n.fieldSearch=void 0}let f={requestedTenant:m,...n.fieldSearch?{fieldSearch:n.fieldSearch}:{}},p=await s.A.post("/case-management/caseCategory/list",f,{params:a}),v=null!=(t=null==p||null==(e=p.data)?void 0:e.data)?t:null==p?void 0:p.data;if(v&&"object"==typeof v&&"success"in v)return v;return{success:!0,data:v}}catch(e){return{success:!1,message:(null==e||null==(n=e.response)||null==(a=n.data)?void 0:a.message)||"Failed to fetch case categories"}}},l=async(e,t)=>{try{let{user:a,requestedTenant:n,...l}=t,i=a?(0,r.jN)(a):Array.isArray(n)?n:[],o={...t,requestedTenant:i};return(await s.A.patch("/case-management/caseCategory/update/".concat(e),o)).data}catch(e){var a,n;return{success:!1,message:(null==e||null==(n=e.response)||null==(a=n.data)?void 0:a.message)||"Failed to update case category"}}},i=async(e,t)=>{try{return(await s.A.patch("/case-management/caseCategory/disbale/".concat(e),{requestedTenant:[t]})).data}catch(e){var a,r;return{success:!1,message:(null==e||null==(r=e.response)||null==(a=r.data)?void 0:a.message)||"Failed to delete case category"}}},o=async e=>{try{return(await s.A.post("/case-management/caseCategory/create",e)).data}catch(e){var t,a;return{success:!1,message:(null==e||null==(a=e.response)||null==(t=a.data)?void 0:t.message)||"Failed to create case category"}}}},25239:(e,t,a)=>{a.d(t,{$t:()=>o,Qc:()=>n,ZJ:()=>i,oL:()=>l});var s=a(65161),r=a(34686);let n=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{let{user:t,fieldSearch:a,requestedTenant:n,...l}=e,i=null!=n?(Array.isArray(n)?n:[n]).map(e=>null==e?"":String(e)).filter(e=>""!==e.trim()):t?(0,r.jN)(t):[],o=Object.fromEntries(Object.entries(l).filter(e=>{let[,t]=e;return null!=t&&("string"!=typeof t||""!==t.trim())})),d={};return i.length>0&&(d.requestedTenant=i),a&&(d.fieldSearch=a),(await s.A.post("/user-management/group/list",d,{params:o})).data}catch(e){var t,a;return{success:!1,message:(null==e||null==(a=e.response)||null==(t=a.data)?void 0:t.message)||"Failed to fetch groups"}}},l=async e=>{try{return(await s.A.post("/user-management/group/create",e)).data}catch(e){var t,a;return{success:!1,message:(null==e||null==(a=e.response)||null==(t=a.data)?void 0:t.message)||"Failed to create group"}}},i=async(e,t)=>{try{return!e.requestedTenant&&t&&(e.requestedTenant=(0,r.jN)(t)),(await s.A.patch("/user-management/group/update",e)).data}catch(e){var a,n;return{success:!1,message:(null==e||null==(n=e.response)||null==(a=n.data)?void 0:a.message)||"Failed to update group"}}},o=async(e,t)=>{try{return(await s.A.patch("/user-management/group/disable",{groupId:e,requestedTenant:null!=t?t:[]})).data}catch(e){var a,r;return{success:!1,message:(null==e||null==(r=e.response)||null==(a=r.data)?void 0:a.message)||"Failed to delete group"}}}},28067:(e,t,a)=>{a.d(t,{t:()=>s});let s=e=>{let t=Array.from(e.matchAll(/<p>([\s\S]*?)<\/p>/gi)).map(e=>e[1])||[];return{root:{children:(t.length?t:[e.replace(/<[^>]+>/g,"")]).map(e=>({children:[{detail:0,format:0,mode:"normal",style:"",text:e.replace(/ /g," ").trim(),type:"text",version:1}],direction:null,format:"",indent:0,type:"paragraph",version:1})),direction:null,format:"",indent:0,type:"root",version:1}}}},30519:(e,t,a)=>{a.d(t,{Ju:()=>f,MV:()=>c,Sd:()=>p,TK:()=>o,kg:()=>l,nr:()=>u,r7:()=>d,sU:()=>n,ux:()=>m});var s=a(65161),r=a(34686);let n=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{let{user:t,fieldSearch:a,includeAllocatedTenantUsers:n,excludePendingUsers:l,excludeTrainingUsers:i,excludeInactiveUsers:o,requestedTenant:d,tenantType:c,...u}=e,m=null==d?[]:Array.isArray(d)?d.map(e=>null==e?null:String(e)):[null==d?null:String(d)],f=m.length>0?m:t?(0,r.jN)(t):[],p=Object.fromEntries(Object.entries(u).filter(e=>{let[,t]=e;return null!=t&&("string"!=typeof t||""!==t.trim())})),v={};return f.length>0&&(v.requestedTenant=f),a&&(v.fieldSearch=a),!0===n&&(v.includeAllocatedTenantUsers=!0),!0===l&&(v.excludePendingUsers=!0),!0===i&&(v.excludeTrainingUsers=!0),!0===o&&(v.excludeInactiveUsers=!0),(await s.A.post("/user-management/user/list",v,{params:p})).data}catch(e){var t,a;return{success:!1,message:(null==e||null==(a=e.response)||null==(t=a.data)?void 0:t.message)||"Failed to fetch tenants"}}},l=async e=>{try{return(await s.A.post("/user-management/user/insert",e)).data}catch(e){var t,a;return{success:!1,message:null==(a=e.response)||null==(t=a.data)?void 0:t.message}}},i=async function(e,t,a){arguments.length>3&&void 0!==arguments[3]&&arguments[3];let r=null==t.requestedTenant||void 0===t.requestedTenant?[null]:Array.isArray(t.requestedTenant)?t.requestedTenant:[t.requestedTenant],n={...t,requestedTenant:r};if(a){let t=new FormData;
1return Object.keys(n).forEach(e=>{let a=n[e];null!=a&&(Array.isArray(a)||"object"==typeof a?t.append(e,JSON.stringify(a)):t.append(e,String(a)))}),t.append("avatar",a),(await s.A.patch(e,t)).data}return(await s.A.patch(e,n)).data},o=async(e,t)=>{try{return await i("/user-management/user/update",e,t)}catch(e){var a,s;return{success:!1,message:(null==e||null==(s=e.response)||null==(a=s.data)?void 0:a.message)||"Failed to update user"}}},d=async(e,t)=>{try{return await i("/user-management/user/profile",e,t,"Failed to update profile")}catch(e){var a,s;return{success:!1,message:(null==e||null==(s=e.response)||null==(a=s.data)?void 0:a.message)||"Failed to update profile"}}},c=async(e,t,a)=>{try{return(await s.A.post("/user-management/user/disable",{userId:e,status:t,requestedTenant:[a]})).data}catch(e){var r,n;return{success:!1,message:null==(n=e.response)||null==(r=n.data)?void 0:r.message}}},u=async(e,t)=>{try{return(await s.A.post("/user-management/user/enable",{userId:e,requestedTenant:[t]})).data}catch(e){var a,r;return{success:!1,message:null==(r=e.response)||null==(a=r.data)?void 0:a.message}}},m=async(e,t)=>{try{return(await s.A.post("/user-management/user/resend",{userId:e,requestedTenant:[t]})).data}catch(e){var a,r;return{success:!1,message:null==(r=e.response)||null==(a=r.data)?void 0:a.message}}},f=async e=>{try{return(await s.A.get("/user-management/user/activation/verify",{params:{token:e}})).data}catch(e){var t,a;return{success:!1,message:(null==e||null==(a=e.response)||null==(t=a.data)?void 0:t.message)||"This activation link is invalid or expired."}}},p=async e=>{try{return(await s.A.post("/user-management/user/activation/set-password",e)).data}catch(e){var t,a;return{success:!1,message:(null==e||null==(a=e.response)||null==(t=a.data)?void 0:t.message)||"Failed to activate account"}}}},36827:(e,t,a)=>{a.d(t,{A:()=>ec,E:()=>eo});var s=a(95155),r=a(12115),n=a(37911),l=a(45981),i=a(70747),o=a(51588),d=a(75257),c=a(26420),u=a(64074),m=a(74331),f=a(13963),p=a(89673),v=a(32345),g=a(48821),x=a(11205),y=a(87928),h=a(64509),b=a(82618),j=a(82936),w=a(3802),N=a(49619),S=a(62861),A=a(22980),_=a(87020),C=a(68160),I=a(83915),k=a(30069),D=a(31376),M=a(6296),O=a(33923),T=a(17463),E=a(93770),F=a(86901);let R=function(e){for(var t=arguments.length,a=Array(t>1?t-1:0),s=1;s<t;s++)a[s-1]=arguments[s];for(let t of a)if(e&&void 0!==e[t]&&null!==e[t])return e[t]},L=["ip","domain","url","hash","email","hostname","username","offense_source"],U={ip:"IP address",domain:"Domain",url:"URL",hash:"File hash",username:"Username",hostname:"Hostname",email:"Email address",offense_source:"Offense source"},B=e=>R(e,"threat_intel","threatIntel"),q=function(e){for(var t=arguments.length,a=Array(t>1?t-1:0),s=1;s<t;s++)a[s-1]=arguments[s];if(!e||"object"!=typeof e)return;let r={};for(let[t,a]of Object.entries(e))r[String(t).toLowerCase().replace(/_/g,"")]=a;for(let e of a){let t=r[e.toLowerCase().replace(/_/g,"")];if(null!=t)return t}},J=e=>{if(!e)return"";let t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})},P=e=>{let{value:t,color:a}=e,r=2*Math.PI*32,n=Math.max(0,Math.min(100,t));return(0,s.jsxs)("div",{className:"relative h-[74px] w-[74px] shrink-0","data-sentry-component":"ConfidenceRing","data-sentry-source-file":"AskDexterModal.tsx",children:[(0,s.jsxs)("svg",{width:"74",height:"74",viewBox:"0 0 74 74",className:"-rotate-90","data-sentry-element":"svg","data-sentry-source-file":"AskDexterModal.tsx",children:[(0,s.jsx)("circle",{cx:"37",cy:"37",r:32,fill:"none",stroke:"var(--border)",strokeWidth:"6","data-sentry-element":"circle","data-sentry-source-file":"AskDexterModal.tsx"}),(0,s.jsx)("circle",{cx:"37",cy:"37",r:32,fill:"none",stroke:a,strokeWidth:"6",strokeDasharray:r,strokeDashoffset:r*(1-n/100),strokeLinecap:"round","data-sentry-element":"circle","data-sentry-source-file":"AskDexterModal.tsx"})]}),(0,s.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[(0,s.jsxs)("span",{className:"font-mono text-[17px] font-bold text-white",children:[n,"%"]}),(0,s.jsx)("span",{className:"text-muted-foreground text-[9px] tracking-wide",children:"confidence"})]})]})},W=e=>{let{level:t}=e;return(0,s.jsx)("div",{className:"bg-muted absolute top-0 -left-[26px] flex h-[17px] w-[17px] items-center justify-center rounded-full border text-[9px] ".concat("flag"===t?"border-red-500/50 text-red-400":"check"===t?"border-emerald-500/50 text-emerald-400":"border-blue-500/50 text-blue-400"),"data-sentry-component":"TimelineDot","data-sentry-source-file":"AskDexterModal.tsx",children:"flag"===t?"!":"check"===t?"â":"i"})},z=e=>{let{entry:t}=e,[a,n]=r.useState(!1),l=(e=>{if(!e||"object"!=typeof e)return"";let{tool:t,...a}=e,s=[];return t&&s.push("tool: ".concat(t)),Object.keys(a).length>0&&s.push("result: ".concat(JSON.stringify(a))),s.join("\n")})(t.data);return(0,s.jsxs)("div",{className:"relative pb-5 last:pb-1","data-sentry-component":"TimelineStep","data-sentry-source-file":"AskDexterModal.tsx",children:[(0,s.jsx)(W,{level:t.level,"data-sentry-element":"TimelineDot","data-sentry-source-file":"AskDexterModal.tsx"}),(0,s.jsxs)("div",{className:"flex items-baseline justify-between gap-3 ".concat(l?"cursor-pointer":""),onClick:()=>l&&n(e=>!e),children:[(0,s.jsx)("span",{className:"min-w-0 text-[13px] font-medium wrap-anywhere text-white",children:t.message}),(0,s.jsxs)("span",{className:"text-muted-foreground font-mono text-[11px] whitespace-nowrap",children:[J(t.at)," ",l&&(0,s.jsx)("span",{className:"inline-block transition-transform ".concat(a?"rotate-90":""),children:"â¸"})]})]}),l&&a&&(0,s.jsx)("pre",{className:"border-border/60 bg-muted text-muted-foreground mt-2 max-w-full overflow-x-auto rounded-md border p-3 font-mono text-[11.5px] leading-relaxed break-all whitespace-pre-wrap",children:l})]})};function G(e){var t,a,n,o,d;let{open:c,offense:u,onInvestigationSaved:m,autoStart:f=!0,showOffenseHeader:p=!0}=e,{t:v}=(0,l.ok)(),[g,x]=r.useState("idle"),[y,h]=r.useState([]),[b,j]=r.useState(null),[w,S]=r.useState(""),[A,_]=r.useState("artifacts"),[C,I]=r.useState(null),W=r.useRef(null),G=r.useRef(!1),$=r.useRef(null),V=r.useRef(null),X=r.useMemo(()=>(e=>{var t;if(!e)return null;let a=e.result;if("string"==typeof a)try{a=JSON.parse(a)}catch(e){a={}}let s=(a=a||{}).verdict||{},r=R(a,"artifact_activity","artifactActivity")||{};return{verdict:e.verdict||R(s,"verdict"),confidence:null!=(t=e.confidence)?t:R(s,"confidence"),severity:R(s,"severity_assessment","severityAssessment"),summary:e.summary||R(s,"summary"),findings:R(s,"findings")||[],recommendations:R(s,"recommendations")||[],artifacts:R(a,"artifacts")||[],assetMatches:R(a,"asset_matches","assetMatches")||[],mitre:R(s,"mitre_te
1chniques","mitreTechniques")||[],relatedOffenses:R(a,"related_offenses","relatedOffenses")||[],relatedNote:R(a,"related_note","relatedNote"),artifactEvents:R(r,"events")||[],artifactActivitySummary:R(r,"summary")||[],artifactEventsTotal:R(r,"events_total","eventsTotal"),artifactSearchNote:R(r,"note"),caseContext:R(a,"case_context","caseContext")||[],caseContextNote:R(a,"case_context_note","caseContextNote"),notes:R(a,"notes")||[],timeline:R(a,"timeline")||[],durationSeconds:R(a,"duration_seconds","durationSeconds"),toolsQueried:R(a,"tools_queried","toolsQueried"),searchNote:R(R(a,"siem_search","siemSearch")||{},"note"),createdAt:R(e,"created_at","createdAt")}})(null==u?void 0:u.investigation),[null==u?void 0:u.investigation]),Q=b||X,H="running"===g?y:(null==Q||null==(t=Q.timeline)?void 0:t.length)?Q.timeline:y;r.useEffect(()=>{if(!c)return;let e="https://platform.socbyte.ai/api/dexter";if(!e){x("error"),S("NEXT_PUBLIC_DEXTER is not configured.");return}let t=(()=>{try{let t=new URL(e,window.location.href),a=t.pathname.replace(/\/$/,"");return{origin:t.origin,path:a?"".concat(a,"/socket.io"):"/socket.io"}}catch(t){return{origin:e,path:"/socket.io"}}})(),a=(0,k.io)(t.origin,{withCredentials:!0,path:t.path,transports:["polling","websocket"]});return W.current=a,a.on("connect_error",e=>{G.current&&(G.current=!1,x("error"),S("Could not connect to Dexter: ".concat((null==e?void 0:e.message)||e)))}),a.on("investigation_progress",e=>{h(t=>[...t,{step:String((null==e?void 0:e.step)||""),message:String((null==e?void 0:e.message)||""),level:null==e?void 0:e.level,at:(null==e?void 0:e.at)||new Date().toISOString(),data:null==e?void 0:e.data}])}),a.on("investigation_result",async e=>{G.current=!1,(null==e?void 0:e.success)?(j((e=>{let t=(null==e?void 0:e.verdict)||{};return{verdict:R(t,"verdict"),confidence:R(t,"confidence"),severity:R(t,"severity_assessment","severityAssessment"),summary:R(t,"summary"),findings:R(t,"findings")||[],recommendations:R(t,"recommendations")||[],artifacts:(null==e?void 0:e.artifacts)||[],assetMatches:R(e,"asset_matches","assetMatches")||[],mitre:R(t,"mitre_te
1chniques","mitreTechniques")||[],relatedOffenses:R(e,"related_offenses","relatedOffenses")||[],relatedNote:R(e,"related_note","relatedNote"),artifactEvents:R(e,"artifact_events","artifactEvents")||[],artifactActivitySummary:R(e,"artifact_activity_summary","artifactActivitySummary")||[],artifactEventsTotal:R(e,"artifact_events_total","artifactEventsTotal"),artifactSearchNote:R(e,"artifact_search_note","artifactSearchNote"),caseContext:R(e,"case_context","caseContext")||[],caseContextNote:R(e,"case_context_note","caseContextNote"),notes:(null==e?void 0:e.notes)||[],timeline:(null==e?void 0:e.timeline)||[],durationSeconds:R(e,"duration_seconds","durationSeconds"),toolsQueried:R(e,"tools_queried","toolsQueried"),searchNote:R(e,"siem_search_note","siemSearchNote")}})(e)),x("done"),(null==e?void 0:e.save_error)?D.toast.error("Investigation finished but could not be saved: ".concat(e.save_error)):D.toast.success("Dexter investigation completed and saved."),(null==e?void 0:e.saved)&&m&&await m()):(x("error"),S((null==e?void 0:e.message)||"Dexter investigation failed."))}),a.on("error",e=>{let t=(null==e?void 0:e.message)||"Dexter encountered an error.";G.current?(G.current=!1,x("error"),S(t)):D.toast.error(t)}),()=>{a.disconnect(),W.current=null,G.current=!1}},[c]);let K=r.useCallback((e,t)=>{let a=W.current;return!!a&&(a.connected?a.emit(e,t):a.once("connect",()=>a.emit(e,t)),!0)},[]),Y=r.useCallback(()=>{if(!(null==u?void 0:u.id)||!(null==u?void 0:u.tenant))return void D.toast.error("Offense or tenant information is missing.");x("running"),h([]),j(null),S(""),G.current=!0,K("execute_investigation",{tenant_id:String(u.tenant),offense_id:String(u.id)})||(G.current=!1,x("error"),S("Dexter connection is not available."))},[null==u?void 0:u.id,null==u?void 0:u.tenant,K]);r.useEffect(()=>{c&&f&&(null==u?void 0:u.id)&&!X&&"idle"===g&&$.current!==u.id&&($.current=u.id,Y())},[c,f,null==u?void 0:u.id,X,g,Y]),r.useEffect(()=>{c||(x("idle"),S(""))},[c]),r.useEffect(()=>{j(null),h([]),x("idle"),S(""),I(null),_("artifacts")},[null==u?void 0:u.id]),r.useEffect(()=>{var e;null==(e=V.current)||e.scrollIntoView({behavior:"smooth",block:"nearest"})},[y]);let Z=Number(null==Q?void 0:Q.confidence),ee=(e=>{let t=String(e||"").toLowerCase();return"true positive"===t||"likely true positive"===t?"#EF4444":"needs review"===t?"#F59E0B":"false positive"===t||"likely false positive"===t?"#22C55E":"#9CA3AF"})(null==Q?void 0:Q.verdict),et=[...H].reverse(),ea=[];(null==Q?void 0:Q.durationSeconds)!==void 0&&(null==Q?void 0:Q.durationSeconds)!==null&&ea.push("Investigated in ".concat(Q.durationSeconds,"s")),(null==Q?void 0:Q.toolsQueried)&&ea.push("".concat(Q.toolsQueried," tools queried")),!b&&(null==Q?void 0:Q.createdAt)&&ea.push("Saved ".concat(J(Q.createdAt)));let es=(null==Q||null==(a=Q.relatedOffenses)?void 0:a.length)||0,er=(null==Q||null==(n=Q.caseContext)?void 0:n.length)||0,en=(null==Q?void 0:Q.artifactEventsTotal)||(null==Q||null==(o=Q.artifactEvents)?void 0:o.length)||0;return(0,s.jsxs)("div",{className:"mx-4 my-4 min-w-0 space-y-4 overflow-x-auto pb-2 text-[13px]","data-sentry-component":"DexterInvestigationView","data-sentry-source-file":"AskDexterModal.tsx",children:[p&&(0,s.jsxs)("div",{className:"bg-card flex flex-wrap items-center justify-between gap-3 rounded-lg p-4",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-3.5",children:[(null==u?void 0:u.severity)&&(0,s.jsx)("span",{className:"rounded-[5px] border px-2.5 py-1 text-[11px] font-bold tracking-wide whitespace-nowrap ".concat((e=>{let t=String(e||"").toLowerCase();return"critical"===t||"high"===t?"bg-red-500/15 text-red-400 border-red-500/40":"medium"===t?"bg-yellow-500/15 text-yellow-400 border-yellow-500/40":"low"===t?"bg-blue-500/15 text-blue-400 border-blue-500/40":"bg-muted text-gray-300 border-border"})(u.severity)),children:u.severity}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("div",{className:"text-muted-foreground text-[11px]",children:["Offense #",(null==u?void 0:u.alertId)||(null==u?void 0:u.id),(null==u?void 0:u.siemSource)?(0,s.jsxs)(s.Fragment,{children:[" \xa0\xb7\xa0 ",u.siemSource]}):null]}),(0,s.jsx)("div",{className:"line-clamp-1 text-[16px] font-semibold text-white",title:(null==u?void 0:u.title)||(null==u?void 0:u.description)||"Offense",children:(null==u?void 0:u.title)||(null==u?void 0:u.description)||"Offense"})]})]}),(0,s.jsxs)("div",{className:"flex shrink-0 flex-wrap items-center gap-2.5",children:[[null==u?void 0:u.tenantName,null==u?void 0:u.offenseSource].filter(
1Boolean).map((e,t)=>(0,s.jsxs)("span",{className:"bg-muted border-border flex max-w-[200px] items-center gap-1.5 rounded-full border px-2.5 py-1 font-mono text-[12px] text-white",children:[(0,s.jsx)("span",{className:"bg-primary h-1.5 w-1.5 shrink-0 rounded-full"}),(0,s.jsx)("span",{className:"truncate",children:e})]},t)),Q&&(0,s.jsx)("span",{className:"text-primary bg-primary/10 border-primary/40 rounded-md border px-2.5 py-1 text-[11px] font-semibold whitespace-nowrap",children:"Dexter reviewed"})]})]}),(0,s.jsxs)("div",{className:"grid gap-4 lg:grid-cols-[380px_minmax(0,1fr)]",children:[(0,s.jsx)("div",{className:"bg-card flex min-w-0 flex-col gap-4 rounded-lg p-4",children:"running"===g?(0,s.jsxs)("div",{className:"flex flex-col items-center gap-3 py-8",children:[(0,s.jsx)(M.A,{className:"text-primary h-8 w-8 animate-spin"}),(0,s.jsx)("p",{className:"text-sm font-medium text-white",children:"Dexter is investigating this alert..."}),(0,s.jsx)("p",{className:"text-muted-foreground text-xs",children:(null==(d=y[y.length-1])?void 0:d.message)||"Starting..."})]}):"error"===g?(0,s.jsxs)("div",{className:"flex flex-col gap-3 py-4",children:[(0,s.jsx)("p",{className:"text-sm wrap-anywhere text-red-400",children:w}),(0,s.jsxs)(i.$,{size:"sm",onClick:Y,className:"w-fit",children:[(0,s.jsx)(O.A,{className:"mr-1 h-4 w-4"})," Try again"]})]}):Q?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)(P,{value:Number.isFinite(Z)?Z:0,color:ee}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"mb-1.5 inline-block rounded-md border px-2.5 py-1 text-[13px] font-bold",style:{color:ee,backgroundColor:"".concat(ee,"1F"),borderColor:"".concat(ee,"59")},children:Q.verdict||"No verdict"}),ea.length>0&&(0,s.jsx)("div",{className:"text-muted-foreground text-[12px]",children:ea.join(" \xb7 ")}),Q.severity&&(0,s.jsxs)("div",{className:"text-muted-foreground text-[12px]",children:["Assessed severity: ",Q.severity]})]})]}),Q.summary&&(0,s.jsx)("div",{className:"border-border/60 border-t pt-3.5 leading-relaxed wrap-anywhere text-white",children:Q.summary}),(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:(0,s.jsxs)(i.$,{size:"sm",onClick:Y,children:[(0,s.jsx)(O.A,{className:"mr-1 h-4 w-4"})," Re-investigate"]})}),(0,s.jsx)("div",{className:"flex gap-2",children:["up","down"].map(e=>(0,s.jsx)("button",{title:"up"===e?"Helpful":"Not helpful",className:"border-border bg-muted flex h-[30px] w-[30px] cursor-pointer items-center justify-center rounded-md border transition-colors hover:text-white ".concat(C===e?"text-white":"text-muted-foreground"),onClick:()=>{I(e),D.toast.success("Thanks for the feedback.")},children:"up"===e?(0,s.jsx)(T.A,{className:"h-3.5 w-3.5"}):(0,s.jsx)(E.A,{className:"h-3.5 w-3.5"})},e))})]}):(0,s.jsxs)("div",{className:"flex flex-col items-center gap-3 py-8",children:[(0,s.jsx)(N.A,{className:"text-primary h-8 w-8"}),(0,s.jsx)("p",{className:"text-muted-foreground text-xs",children:"No investigation yet."}),(0,s.jsxs)(i.$,{size:"sm",onClick:Y,children:[(0,s.jsx)(F.A,{className:"mr-1 h-4 w-4"})," Start investigation"]})]})}),(0,s.jsxs)("div",{className:"bg-card min-w-0 rounded-lg p-4",children:[(0,s.jsx)("div",{className:"border-border no-scrollbar mb-3.5 flex gap-x-3.5 overflow-x-auto border-b",children:[{key:"artifacts",label:"Artifacts"},{key:"mitre",label:"MITRE ATT&CK"},{key:"activity",label:"Log activity".concat(en?" (".concat(en,")"):"")},{key:"related",label:"Related offenses".concat(es?" (".concat(es,")"):"")},{key:"asset",label:"Asset context"},{key:"cases",label:"Case context".concat(er?" (".concat(er,")"):"")}].map(e=>(0,s.jsx)("button",{className:"shrink-0 cursor-pointer border-b-2 bg-transparent px-1 py-2 text-[12px] font-semibold whitespace-nowrap transition-colors ".concat(A===e.key?"border-primary text-white":"text-muted-foreground border-transparent"),onClick:()=>_(e.key),children:e.label},e.key))}),"artifacts"===A&&(0,s.jsx)("div",{children:0===((null==Q?void 0:Q.artifacts)||[]).length?(0,s.jsx)("p",{className:"text-muted-foreground py-4 text-xs",children:"No artifacts extracted."}):(0,s.jsx)("div",{className:"max-h-80 overflow-y-auto",children:L.filter(e=>((null==Q?void 0:Q.artifacts)||[]).some(t=>(null==t?void 0:t.type)===e)).map(e=>{let t=((null==Q?void 0:Q.artifacts)||[]).filter(t=>(null==t?void 0:t.type)===e);return(0,s.jsxs)("div",{className:"mb-3 last:mb-0",children:[(0,s.jsxs)("div",{className:"text-muted-foreground mb-1 text-[11px] font-semibold tracking-wide uppercase",children:[U[e]||e," (",t.length,")"]}),t.map((e,t)=>{let a=(e=>{if((null==e?void 0:e.visibility)==="internal")return{text:"Context",cls:"bg-muted text-muted-foreground border-border"};let t=B(e);return t&&R(t,"found")?{text:"Known IOC",cls:"bg-red-500/15 text-red-400 border-red-500/40"}:(null==e?void 0:e.visibility)==="private"?(null==e?void 0:e.asset)?{text:"Known asset",cls:"bg-emerald-500/15 text-emerald-400 border-emerald-500/40"}:{text:"Internal",cls:"bg-blue-500/15 text-blue-400 border-blue-500/40"}:{text:"No TI match",cls:"bg-muted text-muted-foreground border-border"}})(e),r=B(e),n=r&&R(r,"reports")||[];return(0,s.jsxs)("div",{className:"border-border/60 flex items-start justify-between gap-3 border-b py-2 last:border-b-0",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("span",{className:"block font-mono break-all text-white",children:null==e?void 0:e.value}),(null==e?void 0:e.visibility)==="private"&&(0,s.jsxs)("span",{className:"text-muted-foreground block text-[11px] wrap-anywhere",children:["private",(null==e?void 0:e.asset)?" \xb7 ".concat(R(e.asset,"name")||R(e.asset,"host_name","hostName")).concat(R(e.asset,"owner")?" \xb7 owner: ".concat(R(e.asset,"owner")):""):" \xb7 no asset match"]}),n.length>0&&(0,s.jsx)("div",{className:"mt-1 space-y-0.5",children:n.map((e,t)=>(0,s.jsxs)("div",{className:"text-[11px] wrap-anywhere text-red-300",children:["TI:"," ",q(e,"title")||q(e,"report_id"),q(e,"severity")?" \xb7 ".concat(q(e,"severity")):"",q(e,"source")?" \xb7 ".concat(q(e,"source")):"","default"===q(e,"origin")?" \xb7 platform intel":""]},t))})]}),(0,s.jsx)("span",{className:"shrink-0 rounded-[5px] border px-2 py-0.5 text-[10px] font-bold tracking-wide whitespace-nowrap ".concat(a.cls),children:a.text})]},t)})]},e)})})}),"mitre"===A&&(0,s.jsx)("div",{children:0===((null==Q?void 0:Q.mitre)||[]).length?(0,s.jsx)("p",{className:"text-muted-foreground py-4 text-xs",children:"No MITRE ATT&CK techniques mapped for this offense."}):((null==Q?void 0:Q.mitre)||[]).map((e,t)=>(0,s.jsxs)("div",{className:"border-border/60 flex items-start gap-2.5 border-b py-2.5 last:border-b-0",children:[(0,s.jsx)("span",{className:"text-primary bg-primary/10 mt-0.5 rounded px-1.5 py-0.5 font-mono text-[11px] whitespace-nowrap",children:null==e?void 0:e.id}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("div",{className:"text-[12.5px] wrap-anywhere text-white",children:null==e?void 0:e.name}),(null==e?void 0:e.tactic)&&(0,s.jsx)("div",{className:"text-muted-foreground text-[11px]",children:e.tactic})]})]},t))}),"activity"===A&&((null==Q?void 0:Q.artifactActivitySummary)||[]).length>0&&(0,s.jsxs)("div",{children:[(null==Q?void 0:Q.artifactSearchNote)&&(0,s.jsx)("p",{className:"text-muted-foreground pt-1 pb-2 text-[11px]",children:Q.artifactSearchNote}),(0,s.jsx)("div",{className:"max-h-80 w-0 min-w-full overflow-auto",children:(0,s.jsxs)("table",{className:"w-full min-w-[760px] text-left text-xs",children:[(0,s.jsx)("thead",{className:"bg-card sticky top-0",children:(0,s.jsxs)("tr",{className:"border-border text-muted-foreground border-b",children:[(0,s.jsx)("th",{className:"py-1.5 pr-3 font-medium",children:"Event name"}),(0,s.jsx)("th",{className:"py-1.5 pr-3 font-medium",children:"Log source"}),(0,s.jsx)("th",{className:"py-1.5 pr-3 font-medium",children:"Category"}),(0,s.jsx)("th",{className:"py-1.5 pr-3 text-right font-medium",children:"Src"}),(0,s.jsx)("th",{className:"py-1.5 pr-3 text-right font-medium",children:"Dst"}),(0,s.jsx)("th",{className:"py-1.5 pr-3 text-right font-medium",children:"Ports"}),(0,s.jsx)("th",{className:"py-1.5 pr-3 text-right font-medium",children:"Users"}),(0,s.jsx)("th",{className:"py-1.5 pr-3 text-right font-medium",children:"Mag"}),(0,s.jsx)("th",{className:"py-1.5 text-right font-medium",children:"Events"})]})}),(0,s.jsx)("tbody",{children:((null==Q?void 0:Q.artifactActivitySummary)||[]).map((e,t)=>{var a,r,n,l,i,o,d,c,u;return(0,s.jsxs)("tr",{className:"border-border/60 border-b",children:[(0,s.jsx)("td",{className:"py-1.5 pr-3 text-gray-200",children:(0,s.jsx)("span",{className:"block max-w-[220px] truncate",children:null!=(a=q(e,"event_name","qidname","eventname"))?a:"â"})}),(0,s.jsx)("td",{className:"text-muted-foreground py-1.5 pr-3",children:(0,s.jsx)("span",{className:"block max-w-[160px] truncate",children:null!=(r=q(e,"log_source","logsourcename"))?r:"â"})}),(0,s.jsx)("td",{className:"text-muted-foreground py-1.5 pr-3",children:(0,s.jsx)("span",{className:"block max-w-[150px] truncate",children:null!=(n=q(e,"low_level_category","categoryname"))?n:"â"})}),(0,s.jsx)("td",{className:"text-muted-foreground py-1.5 pr-3 text-right",children:null!=(l=q(e,"source_ip_count"))?l:"â"}),(0,s.jsx)("td",{className:"text-muted-foreground py-1.5 pr-3 text-right",children:null!=(i=q(e,"destination_ip_count"))?i:"â"}),(0,s.jsx)("td",{className:"text-muted-foreground py-1.5 pr-3 text-right",children:null!=(o=q(e,"destination_port_count"))?o:"â"}),(0,s.jsx)("td",{className:"text-muted-foreground py-1.5 pr-3 text-right",children:null!=(d=q(e,"username_count"))?d:"â"}),(0,s.jsx)("td",{className:"text-muted-foreground py-1.5 pr-3 text-right",children:null!=(c=q(e,"max_magnitude"))?c:"â"}),(0,s.jsx)("td",{className:"py-1.5 text-right text-gray-200",children:Number(null!=(u=q(e,"event_c
1ount_sum","event_rows"))?u:0).toLocaleString()})]},t)})})]})})]}),"activity"===A&&0===((null==Q?void 0:Q.artifactActivitySummary)||[]).length&&(0,s.jsx)("div",{children:0===((null==Q?void 0:Q.artifactEvents)||[]).length?(0,s.jsx)("p",{className:"text-muted-foreground py-4 text-xs",children:(null==Q?void 0:Q.artifactSearchNote)||"No log activity was retrieved for this offenseâs artifacts."}):(0,s.jsxs)(s.Fragment,{children:[(null==Q?void 0:Q.artifactSearchNote)&&(0,s.jsx)("p",{className:"text-muted-foreground pt-1 pb-2 text-[11px]",children:Q.artifactSearchNote}),(0,s.jsx)("div",{className:"max-h-72 overflow-y-auto",children:((null==Q?void 0:Q.artifactEvents)||[]).map((e,t)=>{let a=[null==e?void 0:e.sourceip,null==e?void 0:e.sourceport].filter(Boolean).join(":"),r=[null==e?void 0:e.destinationip,null==e?void 0:e.destinationport].filter(Boolean).join(":"),n=(null==e?void 0:e.starttime)?new Date(Number(e.starttime)).toLocaleString():null;return(0,s.jsxs)("div",{className:"border-border/60 border-b py-2 last:border-b-0",children:[(0,s.jsxs)("div",{className:"font-mono text-[12px] break-all text-white",children:[a||"â",r?" â ".concat(r):""]}),(0,s.jsx)("div",{className:"text-muted-foreground mt-0.5 text-[11px]",children:[n,(null==e?void 0:e.username)?"user ".concat(e.username):null,(null==e?void 0:e.eventcount)?"".concat(e.eventcount," events"):null,(null==e?void 0:e.magnitude)!==void 0&&(null==e?void 0:e.magnitude)!==null?"magnitude ".concat(e.magnitude):null].filter(Boolean).join(" \xb7 ")})]},t)})})]})}),"related"===A&&(0,s.jsx)("div",{children:0===es?(0,s.jsx)("p",{className:"text-muted-foreground py-4 text-xs",children:(null==Q?void 0:Q.relatedNote)||"No other offenses from this source were correlated."}):(0,s.jsxs)(s.Fragment,{children:[(null==Q?void 0:Q.relatedNote)&&(0,s.jsx)("p",{className:"text-muted-foreground pt-1 pb-2 text-[11px]",children:Q.relatedNote}),((null==Q?void 0:Q.relatedOffenses)||[]).map((e,t)=>{let a=q(e,"disposition"),r=q(e,"created_at");return(0,s.jsxs)("div",{className:"border-border/60 border-b py-2.5 last:border-b-0",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("span",{className:"min-w-0 text-[12.5px] wrap-anywhere text-white",children:[q(e,"alert_id")||"#".concat(null==e?void 0:e.id),(null==e?void 0:e.description)?" â ".concat(e.description):""]}),(0,s.jsxs)("span",{className:"flex shrink-0 gap-1.5",children:[(null==e?void 0:e.status)&&(0,s.jsx)("span",{className:"bg-muted border-border text-muted-foreground rounded-[5px] border px-2 py-0.5 text-[10px] font-bold tracking-wide whitespace-nowrap",children:e.status}),a&&(0,s.jsx)("span",{className:"rounded-[5px] border px-2 py-0.5 text-[10px] font-bold tracking-wide whitespace-nowrap ".concat(String(a).toLowerCase().includes("false")?"border-emerald-500/40 bg-emerald-500/15 text-emerald-400":"border-red-500/40 bg-red-500/15 text-red-400"),children:a})]})]}),(0,s.jsx)("div",{className:"text-muted-foreground mt-0.5 text-[11px]",children:[r?new Date(r).toLocaleString():null,q(e,"siem_source"),q(e,"source_event_count")?"".concat(Number(q(e,"source_event_count")).toLocaleString()," events"):null,q(e,"occurrence_count")?"occurrence #".concat(q(e,"occurrence_count")):null,q(e,"severity")].filter(Boolean).join(" \xb7 ")})]},t)})]})}),"asset"===A&&(0,s.jsx)("div",{children:0===((null==Q?void 0:Q.assetMatches)||[]).length?(0,s.jsx)("p",{className:"text-muted-foreground py-4 text-xs",children:"No private artifacts matched the tenant's asset inventory."}):((null==Q?void 0:Q.assetMatches)||[]).map((e,t)=>(0,s.jsx)("div",{className:t>0?"border-border mt-4 border-t pt-3":"",children:[["Asset name",R(e,"name")],["Reference ID",R(e,"reference_id","referenceId")],["IP",R(e,"ip")],["Hostname",R(e,"host_name","hostName")],["Type",[R(e,"type"),R(e,"sub_type","subType")].filter(Boolean).join(" / ")],["Group",R(e,"asset_group","assetGroup")],["Site / Location",[R(e,"site"),R(e,"location")].filter(Boolean).join(" / ")],["Owner",R(e,"owner")],["Vendor",R(e,"vendor")],["Application",R(e,"application")]].filter(e=>{let[,t]=e;return!!t}).map((e,t)=>{let[a,r]=e;return(0,s.jsxs)("div",{className:"border-border/60 flex justify-between gap-3 border-b py-2 text-[12px] last:border-b-0",children:[(0,s.jsx)("span",{className:"text-muted-foreground shrink-0",children:a}),(0,s.jsx)("span",{className:"min-w-0 font-mono break-all text-white",children:r})]},t)})},t))}),"cases"===A&&(0,s.jsx)("div",{children:0===((null==Q?void 0:Q.caseContext)||[]).length?(0,s.jsx)("p",{className:"text-muted-foreground py-4 text-xs",children:(null==Q?void 0:Q.caseContextNote)||"No past case analysis mentions this offenseâs artifacts."}):(0,s.jsxs)(s.Fragment,{children:[(null==Q?void 0:Q.caseContextNote)&&(0,s.jsx)("p",{className:"text-muted-foreground pt-1 pb-2 text-[11px]",children:Q.c
1aseContextNote}),(0,s.jsx)("div",{className:"max-h-80 space-y-3 overflow-y-auto",children:((null==Q?void 0:Q.caseContext)||[]).map((e,t)=>{let a=q(e,"matched_artifacts")||[],r=q(e,"analysis_summary")||q(e,"additional_summary")||q(e,"remediations");return(0,s.jsxs)("div",{className:"border-border/60 border-b pb-3 last:border-b-0",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("span",{className:"min-w-0 text-[12.5px] wrap-anywhere text-white",children:[q(e,"reference_id")||q(e,"id"),(null==e?void 0:e.title)?" â ".concat(e.title):""]}),(null==e?void 0:e.status)&&(0,s.jsx)("span",{className:"bg-muted border-border text-muted-foreground shrink-0 rounded-[5px] border px-2 py-0.5 text-[10px] font-bold tracking-wide whitespace-nowrap",children:e.status})]}),(0,s.jsx)("div",{className:"text-muted-foreground mt-0.5 text-[11px]",children:[q(e,"created_at")?new Date(q(e,"created_at")).toLocaleString():null,q(e,"severity"),q(e,"category"),q(e,"tactic")].filter(Boolean).join(" \xb7 ")}),Array.isArray(a)&&a.length>0&&(0,s.jsx)("div",{className:"mt-1 flex flex-wrap gap-1",children:a.map((e,t)=>(0,s.jsx)("span",{className:"text-primary bg-primary/10 border-primary/40 max-w-full rounded border px-1.5 py-0.5 font-mono text-[10px] break-all",children:e},t))}),r&&(0,s.jsx)("p",{className:"mt-1.5 text-[12px] wrap-anywhere whitespace-pre-wrap text-gray-300",children:r})]},t)})})]})})]})]}),(0,s.jsxs)("div",{className:"bg-card rounded-lg px-4 pt-4 pb-2",children:[(0,s.jsx)("h3",{className:"mb-1 text-[16px] font-semibold text-white",children:v("Investigation timeline")}),(0,s.jsx)("div",{className:"text-muted-foreground mb-3 text-[11px] tracking-wider uppercase",children:"Latest activity first"}),0===et.length?(0,s.jsx)("p",{className:"text-muted-foreground pb-3 text-xs",children:"No timeline was recorded for this investigation â run Re-investigate to capture one."}):(0,s.jsxs)("div",{className:"relative mt-3 pl-[26px]",children:[(0,s.jsx)("div",{className:"bg-border absolute top-1 bottom-1 left-2 w-px"}),et.map((e,t)=>(0,s.jsx)(z,{entry:e},"".concat(e.step,"-").concat(e.at,"-").concat(t))),(0,s.jsx)("div",{ref:V})]})]}),Q&&(Q.findings.length>0||Q.recommendations.length>0)&&(0,s.jsxs)("div",{className:"grid gap-4 lg:grid-cols-2",children:[Q.findings.length>0&&(0,s.jsxs)("div",{className:"bg-card min-w-0 rounded-lg p-4",children:[(0,s.jsx)("h3",{className:"mb-2 text-sm font-semibold text-white",children:v("Findings")}),(0,s.jsx)("ul",{className:"list-disc space-y-1.5 pl-5",children:Q.findings.map((e,t)=>(0,s.jsx)("li",{className:"text-[12.5px] wrap-anywhere text-gray-300",children:e},t))})]}),Q.recommendations.length>0&&(0,s.jsxs)("div",{className:"bg-card min-w-0 rounded-lg p-4",children:[(0,s.jsx)("h3",{className:"mb-2 text-sm font-semibold text-white",children:v("Recommendations")}),(0,s.jsx)("ul",{className:"list-disc space-y-1.5 pl-5",children:Q.recommendations.map((e,t)=>(0,s.jsx)("li",{className:"text-[12.5px] wrap-anywhere text-gray-300",children:e},t))})]})]})]})}let $=function(e){let{open:t,onOpenChange:a,offense:r,onInvestigationSaved:l}=e;return(0,s.jsx)(n.a,{heading:"Dexter Investigation".concat((null==r?void 0:r.alertId)?": ".concat(r.alertId):""),open:t,onOpenChange:a,showClose:!0,className:"w-full lg:max-w-6xl","data-sentry-element":"Modal","data-sentry-component":"AskDexterModal","data-sentry-source-file":"AskDexterModal.tsx",children:(0,s.jsx)(G,{open:t,offense:r,onInvestigationSaved:l,"data-sentry-element":"DexterInvestigationView","data-sentry-source-file":"AskDexterModal.tsx"})})};function V(e){let{offense:t,active:a,onInvestigationSaved:r,onOpenDexter:n}=e;return(null==t?void 0:t.investigation)?(0,s.jsx)(G,{open:a,offense:t,onInvestigationSaved:r,autoStart:!1,showOffenseHeader:!1,"data-sentry-element":"DexterInvestigationView","data-sentry-component":"DexterInvestigationTab","data-sentry-source-file":"DexterInvestigationTab.tsx"}):(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center gap-3 py-10 text-center",children:[(0,s.jsx)(N.A,{className:"text-muted-foreground h-8 w-8"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium text-white",children:"Dexter hasn't investigated this offense yet."}),(0,s.jsx)("p",{className:"text-muted-foreground mt-1 text-xs",children:"Run an investigation to gather artifacts, related offenses and a verdict."})]}),(0,s.jsxs)(i.$,{size:"sm",onClick:n,children:[(0,s.jsx)(O.A,{className:"mr-1 h-4 w-4"})," Investigate with Dexter"]})]})}var X=a(1940),Q=a(6815),H=a(87136),K=a(92500),Y=a(80415),Z=a(90540),ee=a(49084),et=a(4632),ea=a(59118),es=a(82572);let er=e=>{var t,a;return String(null!=(a=null!=(t=null==e?void 0:e.reviewedBy)?t:null==e?void 0:e.reviewed_by)?a:"").trim()},en=e=>Array.isArray(null==e?void 0:e.comments)?e.comments:[],el="/api/v2/SIEM/offense/review",ei=(e,t)=>{let a=null==e?void 0:e.permissions;
1if(!Array.isArray(a))return!0;let s=String(t).trim();return a.some(e=>{let t="string"==typeof e?e:null==e?void 0:e.action;if(!t||"string"!=typeof t)return!1;if(t===s)return!0;if(!t.includes("/:"))return!1;let a=t.split("/").filter(Boolean),r=s.split("/").filter(Boolean);if(a.length!==r.length)return!1;for(let e=0;e<a.length;e+=1)if(!a[e].startsWith(":")&&a[e]!==r[e])return!1;return!0})},eo=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=" ".repeat(t);if(null===e)return(0,s.jsx)("span",{className:"text-gray-400",children:"null"});if("string"==typeof e)return(0,s.jsxs)("span",{className:"break-words whitespace-pre-wrap text-white",style:{overflowWrap:"anywhere",wordBreak:"break-word"},children:['"',e,'"']});if("number"==typeof e||"boolean"==typeof e)return(0,s.jsx)("span",{className:"text-blue-400",children:String(e)});if(Array.isArray(e))return 0===e.length?(0,s.jsx)("span",{className:"text-white",children:"[]"}):(0,s.jsxs)("div",{className:"w-full max-w-full min-w-0",children:[(0,s.jsx)("span",{className:"text-white",children:"["}),(0,s.jsx)("br",{}),e.map((r,n)=>(0,s.jsxs)("div",{className:"block w-full max-w-full min-w-0",children:[(0,s.jsxs)("span",{className:"whitespace-pre",children:[a," "]}),(0,s.jsx)("span",{className:"break-words whitespace-pre-wrap",style:{overflowWrap:"anywhere",wordBreak:"break-word"},children:eo(r,t+1)}),n<e.length-1&&(0,s.jsx)("span",{className:"text-white",children:","}),(0,s.jsx)("br",{})]},n)),(0,s.jsx)("span",{className:"whitespace-pre",children:a}),(0,s.jsx)("span",{className:"text-white",children:"]"})]});if("object"==typeof e){let r=Object.keys(e);return 0===r.length?(0,s.jsx)("span",{className:"text-white",children:"{}"}):(0,s.jsxs)("div",{className:"w-full max-w-full min-w-0",children:[(0,s.jsx)("span",{className:"text-white",children:"{"}),(0,s.jsx)("br",{}),r.map((n,l)=>(0,s.jsxs)("div",{className:"block w-full max-w-full min-w-0",children:[(0,s.jsxs)("span",{className:"whitespace-pre",children:[a," "]}),(0,s.jsxs)("span",{className:"break-words whitespace-pre-wrap text-green-400",style:{overflowWrap:"anywhere",wordBreak:"break-word"},children:['"',n,'"']}),(0,s.jsx)("span",{className:"text-white",children:": "}),(0,s.jsx)("span",{className:"break-words whitespace-pre-wrap",style:{overflowWrap:"anywhere",wordBreak:"break-word"},children:eo(e[n],t+1)}),l<r.length-1&&(0,s.jsx)("span",{className:"text-white",children:","}),(0,s.jsx)("br",{})]},n)),(0,s.jsx)("span",{className:"whitespace-pre",children:a}),(0,s.jsx)("span",{className:"text-white",children:"}"})]})}return(0,s.jsx)("span",{className:"break-words whitespace-pre-wrap text-white",style:{overflowWrap:"anywhere",wordBreak:"break-word"},"data-sentry-component":"renderJsonWithSyntaxHighlighting","data-sentry-source-file":"OffenseDetailModal.tsx",children:String(e)})},ed=()=>(0,s.jsxs)("div",{className:"mx-4 my-4 space-y-4","aria-busy":"true","data-sentry-component":"OffenseDetailSkeleton","data-sentry-source-file":"OffenseDetailModal.tsx",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsx)(u.E,{className:"h-6 w-1/2","data-sentry-element":"Skeleton","data-sentry-source-file":"OffenseDetailModal.tsx"}),(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,s.jsx)(u.E,{className:"h-6 w-24","data-sentry-element":"Skeleton","data-sentry-source-file":"OffenseDetailModal.tsx"}),(0,s.jsx)(u.E,{className:"h-6 w-6 rounded-md","data-sentry-element":"Skeleton","data-sentry-source-file":"OffenseDetailModal.tsx"})]})]}),(0,s.jsx)("div",{className:"bg-card grid grid-cols-2 gap-4 rounded-lg p-4 md:grid-cols-3",children:Array.from({length:9}).map((e,t)=>(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(u.E,{className:"h-3 w-20"}),(0,s.jsx)(u.E,{className:"h-4 w-32"})]},t))}),(0,s.jsxs)("div",{className:"bg-card space-y-2 rounded-lg p-4",children:[(0,s.jsx)(u.E,{className:"h-3 w-28","data-sentry-element":"Skeleton","data-sentry-source-file":"OffenseDetailModal.tsx"}),(0,s.jsx)(u.E,{className:"h-4 w-full","data-sentry-element":"Skeleton","data-sentry-source-file":"OffenseDetailModal.tsx"}),(0,s.jsx)(u.E,{className:"h-4 w-11/12","data-sentry-element":"Skeleton","data-sentry-source-file":"OffenseDetailModal.tsx"}),(0,s.jsx)(u.E,{className:"h-4 w-2/3","data-sentry-element":"Skeleton","data-sentry-source-file":"OffenseDetailModal.tsx"})]}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(u.E,{className:"h-8 w-24","data-sentry-element":"Skeleton","data-sentry-source-file":"OffenseDetailModal.tsx"}),(0,s.jsx)(u.E,{className:"h-8 w-28","data-sentry-element":"Skeleton","data-sentry-source-file":"OffenseDetailModal.tsx"})]}),(0,s.jsx)("div",{className:"bg-card space-y-3 rounded-lg p-4",children:Array.from({length:5}).map((e,t)=>(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(u.E,{className:"h-4 w-40 shrink-0"}),(0,s.jsx)(u.E,{className:"h-4 flex-1"})]},t))})]})]});function ec(e){var t,a,u,k,M,O,T;let{open:E,setOpen:F,caseData:R,onEdit:L,onDelete:U,onListRefresh:B,attackModal:q=!1}=e,{t:J}=(0,l.ok)(),{user:P}=(0,A.J)(),W="https://platform.socbyte.ai/api/casemanagement".replace(/\/+$/,""),[z,G]=(0,r.useState)(R.status||"N/A"),[ec,eu]=(0,r.useState)(R),[em,ef]=(0,r.useState)(!1),[ep,ev]=(0,r.useState)("json"),eg=r.useRef(!1),[ex,ey]=(0,r.useState)(!1),eh=(0,r.useMemo)(()=>{let e=null==ec?void 0:ec.jsonData;return!e||"object"!=typeof e},[null==ec?void 0:ec.jsonData]),eb=async()=>{var e,t,a,s,r,n;try{if(q)return void eu(R);let r=await (0,_.qT)(ec.id,null==ec?void 0:ec.tenant);if((null==r?void 0:r.success)===!1)return void D.toast.error((null==r?void 0:r.message)||"Failed to fetch offense detail");let n=(null==r||null==(e=r.data)?void 0:e.data)||(null==r?void 0:r.data)||(null==r?void 0:r.offense)||r||ec;if(eu(n),(null==n?void 0:n.status)&&G(n.status),(null==n?void 0:n.id)&&(null==n?void 0:n.tenant)){let e=P?await (0,Y.Bl)(String(n.id),String(n.tenant),P):null,r=(0,Y.XB)(e);eM(null!=(t=null==r?void 0:r.draftCaseId)?t:null),eT(null!=(s=null!=(a=null==r?void 0:r.activeCaseId)?a:null==n?void 0:n.caseId)?s:null)}else eM(null),eT(null)}catch(e){D.toast.error((null==e||null==(n=e.response)||null==(r=n.data)?void 0:r.message)||(null==e?void 0:e.message)||"Failed to fetch offense detail")}};r.useEffect(()=>{E&&(null==ec?void 0:ec.id)&&!eg.current&&(eg.current=!0,ey(!0),eb().finally(()=>ey(!1)))},[E,null==ec?void 0:ec.id]),r.useEffect(()=>{E||(eg.current=!1,ey(!1))},[E]);let[ej,ew]=(0,r.useState)(null);r.useEffect(()=>{if(!E)return void ew(null);let e=null==ec?void 0:ec.siemSource,t=null==ec?void 0:ec.siemOffenseId,a=null==ec?void 0:ec.tenant;if(!e||!t||!a)return void ew(null);let s=!1;
1return(0,C.vx)(String(e),String(t),String(a)).then(e=>{s||ew(e)}),()=>{s=!0}},[E,null==ec?void 0:ec.siemSource,null==ec?void 0:ec.siemOffenseId,null==ec?void 0:ec.tenant]);let eN=(0,r.useMemo)(()=>{if(!ej)return null;if("template"===ej.type)return ej.url;if("native_field"===ej.type&&ej.native_field){var e;let t=null==ec||null==(e=ec.jsonData)?void 0:e[ej.native_field],a="string"==typeof t?t.trim():"";return/^https?:\/\//i.test(a)?a:null}return null},[ej,null==ec?void 0:ec.jsonData]),[eS,eA]=(0,r.useState)(!1),[e_,eC]=(0,r.useState)(!1),[eI,ek]=(0,r.useState)(!1),[eD,eM]=(0,r.useState)(null),[eO,eT]=(0,r.useState)(null),[eE,eF]=(0,r.useState)(!1),[eR,eL]=(0,r.useState)(!1),[eU,eB]=(0,r.useState)(!1),[eq,eJ]=(0,r.useState)(!1),[eP,eW]=(0,r.useState)(!1),ez=e=>{if(!e)return"N/A";let t=new Date(e);return isNaN(t.getTime())?"N/A":t.toLocaleString(void 0,{year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit"})},eG=(0,r.useMemo)(()=>(0,ee.Qk)({status:z,assignedTo:null==ec?void 0:ec.assignedTo,assignedAt:null==ec?void 0:ec.assignedAt,comments:en(ec),userId:null==P?void 0:P.userId}),[z,ec,null==P?void 0:P.userId]),e$=(0,r.useMemo)(()=>{var e,t,a;return(0,ee.mr)({status:null==ec?void 0:ec.status,assignedTo:null!=(e=null==ec?void 0:ec.assignedTo)?e:null==ec?void 0:ec.assigned_to,assignedAt:null!=(t=null==ec?void 0:ec.assignedAt)?t:null==ec?void 0:ec.assigned_at,reviewedBy:er(ec),reviewedAt:null!=(a=null==ec?void 0:ec.reviewedAt)?a:null==ec?void 0:ec.reviewed_at,comments:en(ec),userId:null==P?void 0:P.userId})},[ec,null==P?void 0:P.userId]),eV=(0,r.useMemo)(()=>{let e=String((null==P?void 0:P.userId)||"").trim(),t=er(ec)||er(R);return!!e&&!!t&&e===t},[ec,R,null==P?void 0:P.userId]),eX=e=>{let t=String(z||"").toLowerCase().replace(/\s+/g,""),a="assigned"===t?"inprogress":t;if("inprogress"===a||"assigned"===a){if(eG)return void D.toast.error(eG)}else if("reviewed"===a&&!eV)return void D.toast.error("Only the user who reviewed this offense can close the offense, save a case draft, create a case, or update the case.");if("case"===e||"caseWithDexter"===e){if(eO){D.toast.error("A case already exists for this offense."),eJ(!0);return}let t="caseWithDexter"===e;if(t&&!(null==ec?void 0:ec.investigation))return void D.toast.error("Run a Dexter investigation on this offense first, then create the case.");if(ek(t),eD){eF(!0),eC(!0);return}return eF(!1),void eC(!0)}eL(!0)},eQ=(0,r.useMemo)(()=>!!ei(P,el)&&en(ec).some(e=>{var t,a;return!!(null==(a=null!=(t=null==e?void 0:e.isActive)?t:null==e?void 0:e.is_active)||a)}),[ec,P]),eH=(0,r.useMemo)(()=>!!ei(P,"/api/v2/SIEM/offense/link-case")&&!String((null==ec?void 0:ec.caseId)||"").trim()&&!eO&&!eD,[null==ec?void 0:ec.caseId,eO,eD,P]);return ex?(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(n.a,{heading:"Offense Reference ID: ".concat(ec.alertId||"N/A"),open:E,onOpenChange:F,showClose:!0,className:"w-full lg:max-w-5xl",children:(0,s.jsx)(ed,{})})}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(n.a,{heading:"Offense Reference ID: ".concat(ec.alertId||"N/A"),open:E,onOpenChange:F,showClose:!0,className:"w-full lg:max-w-5xl","data-sentry-element":"Modal","data-sentry-source-file":"OffenseDetailModal.tsx",children:[(0,s.jsxs)("div",{className:"mx-4 my-4 space-y-4",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsx)("div",{className:"min-w-0 flex-1",children:(0,s.jsx)("h2",{className:"text-lg font-semibold text-white",children:null!=(O=null!=(M=null==(t=ec.jsonData)?void 0:t.title)?M:ec.description)?O:"Offense ".concat(ec.siemOffenseId)})}),(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[!!(null==ec?void 0:ec.assignedTo)&&!!(null==ec?void 0:ec.dexterEnabled)&&(0,s.jsxs)(i.$,{size:"sm",variant:"outline",className:"h-6 gap-1 px-2 text-xs",onClick:()=>ef(!0),children:[(0,s.jsx)(N.A,{className:"h-3.5 w-3.5"}),"Ask Dexter"]}),(0,s.jsxs)(o.rI,{"data-sentry-element":"DropdownMenu","data-sentry-source-file":"OffenseDetailModal.tsx",children:[(0,s.jsx)(o.ty,{asChild:!0,"data-sentry-element":"DropdownMenuTrigger","data-sentry-source-file":"OffenseDetailModal.tsx",children:(0,s.jsxs)(i.$,{variant:"ghost",size:"icon",className:"bg-muted hover:bg-muted/80 h-6 w-6 p-1 transition-colors","data-sentry-element":"Button","data-sentry-source-file":"OffenseDetailModal.tsx",children:[(0,s.jsx)("span",{className:"sr-only",children:"Open actions"}),(0,s.jsx)(f.A,{className:"h-4 w-4","data-sentry-element":"IconDotsVertical","data-sentry-source-file":"OffenseDetailModal.tsx"})]})}),(0,s.jsxs)(o.SQ,{align:"end",className:"min-w-[200px]","data-sentry-element":"DropdownMenuContent","data-sentry-source-file":"OffenseDetailModal.tsx",children:[(0,s.jsx)(o.lp,{"data-sentry-element":"DropdownMenuLabel","data-sentry-source-file":"OffenseDetailModal.tsx",children:"Actions"}),(0,s.jsx)(o.mB,{"data-sentry-element":"DropdownMenuSeparator","data-sentry-source-file":"OffenseDetailModal.tsx"}),(()=>{let e=String(z||"").toLowerCase().replace(/\s+/g,""),t=[],a=(0,s.jsxs)(o._2,{onClick:async()=>{let e=(0,ee.Hy)({status:null==ec?void 0:ec.status,assignedTo:null==ec?void 0:ec.assignedTo,assignedAt:null==ec?void 0:ec.assignedAt,comments:en(ec),userId:null==P?void 0:P.userId});if(e)return void D.toast.error(e);try{let e=await (0,_.gC)([ec.id],(null==ec?void 0:ec.tenant)?[String(ec.tenant)]:[]);(null==e?void 0:e.success)?(D.toast.success("Offense escalated successfully"),await eb(),B&&await B()):D.toast.error((null==e?void 0:e.message)||ee.GW||"Failed to escalate offense")}catch(e){D.toast.error((null==e?void 0:e.message)||"Failed to escalate offense")}},children:[(0,s.jsx)(S.A,{className:"h-4 w-4 text-[var(--editIcon)]"}),"Escalate"]},"escalate"),r=(0,s.jsxs)(o._2,{onClick:async()=>
1{if(!ei(P,el))return void D.toast.error("You do not have permission to review this offense.");if(!eQ)return void D.toast.error("At least one comment is required before the offense can be reviewed.");try{let e=await (0,_.Q6)([ec.id],(null==ec?void 0:ec.tenant)?[String(ec.tenant)]:[]);(null==e?void 0:e.success)?(D.toast.success("Offense reviewed successfully"),await eb(),B&&await B()):D.toast.error((null==e?void 0:e.message)||"Failed to review")}catch(e){D.toast.error((null==e?void 0:e.message)||"Failed to review")}},children:[(0,s.jsx)(p.A,{className:"h-4 w-4 text-[var(--review-text)]"}),"Review"]},"review"),n=(0,s.jsxs)(o._2,{onClick:()=>eX("case"),children:[(0,s.jsx)(v.A,{className:"h-4 w-4 text-[var(--Status-pending)]"}),"Case"]},"case"),l=(0,s.jsxs)(o._2,{onClick:()=>eX("caseWithDexter"),children:[(0,s.jsx)(N.A,{className:"h-4 w-4 text-[var(--Status-pending)]"}),"Create Case with Dexter"]},"case-dexter"),i=(0,s.jsxs)(o._2,{onClick:()=>eB(!0),children:[(0,s.jsx)(g.A,{className:"h-4 w-4 text-[var(--Status-pending)]"}),"Link to Case"]},"link-case"),d=(0,s.jsxs)(o._2,{onClick:()=>eX("close"),children:[(0,s.jsx)(x.A,{className:"h-4 w-4 text-[var(--primary)]"}),"Close"]},"close"),c=(0,s.jsxs)(o._2,{onClick:async()=>{try{let e=await (0,_.Gu)([ec.id],(null==ec?void 0:ec.tenant)?[String(ec.tenant)]:[]);(null==e?void 0:e.success)?(D.toast.success("Assigned to you successfully"),await eb(),B&&await B()):D.toast.error((null==e?void 0:e.message)||"You do not have permission to assign offenses.")}catch(e){D.toast.error((null==e?void 0:e.message)||"You do not have permission to assign offenses.")}},children:[(0,s.jsx)(y.A,{className:"h-4 w-4 text-[var(--viewIcon)]"}),"Assign to Me"]},"assign-me"),u=(0,s.jsxs)(o._2,{onClick:()=>eA(!0),children:[(0,s.jsx)(h.A,{className:"h-4 w-4 text-[var(--viewIcon)]"}),"Assign to User"]},"assign-other"),m=(0,s.jsxs)(o._2,{onClick:async()=>{try{let e=await (0,_.p3)([ec.id],(null==ec?void 0:ec.tenant)?[String(ec.tenant)]:[]);(null==e?void 0:e.success)?(D.toast.success("Reopened successfully"),await eb(),B&&await B()):D.toast.error((null==e?void 0:e.message)||"Failed to reopen")}catch(e){D.toast.error((null==e?void 0:e.message)||"Failed to reopen")}},children:[(0,s.jsx)(b.A,{className:"h-4 w-4 text-[var(--primary)]"}),"Reopen"]},"reopen");switch(e){case"open":t.push(c,u);break;case"inprogress":case"assigned":t.push(a,n,l),eH&&t.push(i),t.push(d);break;case"escalated":t.push(r);break;case"reviewed":t.push(n,l),eH&&t.push(i),t.push(d);break;case"cased":t.push(d);break;case"closed":t.push(m);break;case"reopened":t.push(c,u,d)}return t})()]})]})]})]}),(0,s.jsxs)("div",{className:"bg-card grid grid-cols-2 gap-4 rounded-lg p-4 text-sm md:grid-cols-3",children:[(0,s.jsx)(ea.W7,{label:"Created At",value:ez(ec.createdAt),"data-sentry-element":"InfoItem","data-sentry-source-file":"OffenseDetailModal.tsx"}),(0,s.jsx)(ea.W7,{label:"Severity",value:(0,s.jsx)(c.E,{...(e=>{switch(String(e||"").toLowerCase()){case"high":return{className:"bg-[var(--open)]/20 text-[var(--open-text)] "};case"medium":return{className:"bg-[var(--escalated)]/20 text-[var(--escalated-text)] "};case"low":return{className:"bg-[var(--inprogress)]/20 text-[var(--inprogress-text)] "};default:return{className:"bg-gray-600 text-white hover:bg-gray-700"}}})(ec.severity),children:ec.severity||"N/A"}),"data-sentry-element":"InfoItem","data-sentry-source-file":"OffenseDetailModal.tsx"}),(0,s.jsx)(ea.W7,{label:"Source ID",scope:"offense",value:eN&&ec.siemOffenseId?(0,s.jsxs)("a",{href:eN,target:"_blank",rel:"noopener noreferrer",title:(null==ej?void 0:ej.integration_name)?"Open in ".concat(ej.integration_name):"Open in ".concat(ec.siemSource||"source tool"),className:"inline-flex items-center gap-1 break-all text-[var(--primary)] underline decoration-dotted underline-offset-2 hover:
1decoration-solid",children:[ec.siemOffenseId,(0,s.jsx)(j.A,{className:"h-3.5 w-3.5 shrink-0"})]}):(0,s.jsx)("span",{className:"break-all",children:ec.siemOffenseId||"N/A"}),"data-sentry-element":"InfoItem","data-sentry-source-file":"OffenseDetailModal.tsx"}),(0,s.jsx)(ea.W7,{label:"Status",value:(0,s.jsx)(c.E,{...(e=>{switch(String(e||"").toLowerCase()){case"open":case"reopened":return{className:"bg-[var(--open)]/20 text-[var(--open-text)]"};case"closed":return{className:"bg-[var(--close)]/20 text-[var(--close-text)]"};case"reviewed":return{className:"bg-[var(--review)]/20 text-[var(--review-text)]"};case"cased":return{className:"bg-[var(--case)]/20 text-[var(--case-text)]"};case"inprogress":return{className:"bg-[var(--inprogress)]/20 text-[var(--inprogress-text)]"};case"escalated":return{className:"bg-[var(--escalated)]/20 text-[var(--escalated-text)]"};default:return{className:"bg-gray-600 text-white hover:bg-gray-700"}}})(z),children:(0,et.tb)(z)}),"data-sentry-element":"InfoItem","data-sentry-source-file":"OffenseDetailModal.tsx"}),(0,s.jsx)(ea.W7,{label:"Tenant",value:ec.tenantName||"N/A","data-sentry-element":"InfoItem","data-sentry-source-file":"OffenseDetailModal.tsx"}),(0,s.jsx)(ea.W7,{label:"Updated At",value:ez(ec.updatedAt),"data-sentry-element":"InfoItem","data-sentry-source-file":"OffenseDetailModal.tsx"}),ec.caseId&&(0,s.jsx)(ea.W7,{label:"Case ID",scope:"offense",value:(0,s.jsx)("button",{type:"button",onClick:()=>eJ(!0),className:"min-w-0 cursor-pointer border-0 bg-transparent p-0 text-left text-sm leading-snug font-normal break-all text-[var(--primary)] hover:underline",children:ec.caseId})}),(0,s.jsx)(ea.W7,{label:"Disposition",scope:"offense",value:ec.disposition||"N/A","data-sentry-element":"InfoItem","data-sentry-source-file":"OffenseDetailModal.tsx"}),(0,s.jsx)(ea.W7,{label:"Source",value:ec.siemSource||"N/A","data-sentry-element":"InfoItem","data-sentry-source-file":"OffenseDetailModal.tsx"}),(0,s.jsx)(ea.W7,{label:"Offense Source",scope:"offense",value:ec.offenseSource||"N/A","data-sentry-element":"InfoItem","data-sentry-source-file":"OffenseDetailModal.tsx"}),(0,s.jsx)(ea.W7,{label:"Offense ID",scope:"offense",value:ec.id||"N/A","data-sentry-element":"InfoItem","data-sentry-source-file":"OffenseDetailModal.tsx"})]})]}),(0,s.jsx)("div",{className:"mx-4 mb-4",children:(0,s.jsxs)(d.Zp,{className:"p-4","data-sentry-element":"Card","data-sentry-source-file":"OffenseDetailModal.tsx",children:[(0,s.jsxs)("h3",{className:"mb-3 flex items-center font-semibold text-white",children:[(0,s.jsx)(y.A,{className:"mr-2 h-4 w-4 text-[var(--primary)]","data-sentry-element":"IconUser","data-sentry-source-file":"OffenseDetailModal.tsx"})," ",J("Assignment Details")]}),ec.assignedTo||ec.escalatedAt||er(ec)||ec.reviewedAt||(null==ec?void 0:ec.reviewed_at)||ec.closedBy||ec.assignedBy?(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-2 space-y-2 md:grid-cols-2",children:[ec.assignedTo&&(0,s.jsxs)("div",{className:"flex items-start gap-2 border-l-2 border-[var(--primary)] pl-2",children:[(0,s.jsx)(y.A,{className:"mt-1 h-4 w-4 text-[var(--primary)]"}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"text-sm text-white",children:["Assigned To: ",ec.assignedToName]}),(0,s.jsxs)("p",{className:"text-muted-foreground text-xs",children:["At:"," ",ec.assignedAt?ez(ec.assignedAt):"N/A"]})]})]}),ec.assignedBy&&(0,s.jsxs)("div",{className:"flex items-start gap-2 border-l-2 border-[var(--primary)] pl-2",children:[(0,s.jsx)(y.A,{className:"mt-1 h-4 w-4 text-[var(--primary)]"}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"text-sm text-white",children:["Assigned By: ",ec.assignedByName]}),(0,s.jsxs)("p",{className:"text-muted-foreground text-xs",children:["At:"," ",ec.assignedAt?ez(ec.assignedAt):"N/A"]})]})]}),ec.escalatedAt&&(0,s.jsxs)("div",{className:"flex items-start gap-2 border-l-2 border-[var(--primary)] pl-2",children:[(0,s.jsx)(S.A,{className:"mt-1 h-4 w-4 text-[var(--primary)]"}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"text-sm text-white",children:["Escalated By: ",ec.escalatedByName||"Unknown"]}),(0,s.jsxs)("p",{className:"text-muted-foreground text-xs",children:["At: ",ez(ec.escalatedAt)]})]})]}),(er(ec)||ec.reviewedAt||(null==ec?void 0:ec.reviewed_at))&&(0,s.jsxs)("div",{className:"flex items-start gap-2 border-l-2 border-[var(--primary)] pl-2",children:[(0,s.jsx)(w.A,{className:"mt-1 h-4 w-4 text-[var(--primary)]"}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"text-sm text-white",children:["Reviewed By:"," ",ec.reviewedByName||(null==ec?void 0:ec.reviewed_by_name)||"Unknown"]}),(0,s.jsxs)("p",{className:"text-muted-foreground text-xs",children:["At:"," ",ec.reviewedAt||(null==ec?void 0:ec.reviewed_at)?ez(ec.reviewedAt||(null==ec?void 0:ec.reviewed_at)):"N/A"]})]})]})]}):(0,s.jsx)(es.I,{title:"No assignment details available"})]})}),(0,s.jsx)("div",{className:"mx-4 mb-4",children:(0,s.jsxs)(m.tU,{defaultValue:"json",value:ep,onValueChange:ev,"data-sentry-element":"Tabs","data-sentry-source-file":"OffenseDetailModal.tsx",children:[(0,s.jsxs)(m.j7,{"data-sentry-element":"TabsList","data-sentry-source-file":"OffenseDetailModal.tsx",children:[(0,s.jsx)(m.Xi,{value:"json","data-sentry-element":"TabsTrigger","data-sentry-source-file":"OffenseDetailModal.tsx",children:"Details"}),(0,s.jsx)(m.Xi,{value:"dexter","data-sentry-element":"TabsTrigger","data-sentry-source-file":"OffenseDetailModal.tsx",children:"Dexter Investigation"}),(0,s.jsx)(m.Xi,{value:"comments","data-sentry-element":"TabsTrigger","data-sentry-source-file":"OffenseDetailModal.tsx",children:"Comments"}),(0,s.jsx)(m.Xi,{value:"timeline","data-sentry-element":"TabsTrigger","data-sentry-source-file":"OffenseDetailModal.tsx",children:"Timeline"})]}),(0,s.jsx)(m.av,{value:"dexter",className:"bg-card rounded-lg px-4 py-2","data-sentry-element":"TabsContent","data-sentry-source-file":"OffenseDetailModal.tsx",children:(0,s.jsx)(V,{active:"dexter"===ep,offense:{id:null==ec?void 0:ec.id,tenant:null==ec?void 0:ec.tenant,alertId:null==ec?void 0:ec.alertId,severity:null==ec?void 0:ec.severity,description:null==ec?void 0:ec.description,title:null==ec||null==(a=ec.jsonData)?void 0:a.title,offenseSource:null==ec?void 0:ec.offenseSource,tenantName:null==ec?void 0:ec.tenantName,siemSource:null==ec?void 0:ec.siemSource,investigation:null==ec?void 0:ec.investigation},onInvestigationSaved:async()=>{await eb(),B&&await B()},onOpenDexter:()=>ef(!0),"data-sentry-element":"DexterInvestigationTab","data-sentry-source-file":"OffenseDetailModal.tsx"})}),(0,s.jsx)(m.av,{value:"comments",className:"bg-card rounded-lg px-4 py-2","data-sentry-element":"TabsContent","data-sentry-source-file":"OffenseDetailModal.tsx",children:(0,s.jsx)(K.A,{comments:(null==ec?void 0:ec.comments)||[],currentUserId:null==P?void 0:P.userId,maxImages:
15,mediaApiBase:W,canComment:e$.canComment,commentHint:e$.hint,onPost:async(e,t,a)=>{let s=await (0,_.E4)({ids:[ec.id],parentComment:a,comment:e,commented_image_url:t,requestedTenant:(null==ec?void 0:ec.tenant)?[String(ec.tenant)]:[]});return{success:!!(null==s?void 0:s.success),message:null==s?void 0:s.message}},onUpdate:async(e,t,a,s)=>{let r=await (0,_.bG)(e,{comment:t,commented_image_url:a,existingImageIds:s.existingImageIds,existingImageUrls:s.existingImageUrls,removeCommentedImage:s.removeCommentedImage,requestedTenant:(null==ec?void 0:ec.tenant)?[String(ec.tenant)]:[]});return{success:!!(null==r?void 0:r.success),message:null==r?void 0:r.message}},onRefresh:async()=>{await eb(),B&&await B()},"data-sentry-element":"CommentSection","data-sentry-source-file":"OffenseDetailModal.tsx"})}),(0,s.jsxs)(m.av,{value:"json",className:"bg-card rounded-lg px-4 py-2","data-sentry-element":"TabsContent","data-sentry-source-file":"OffenseDetailModal.tsx",children:[(0,s.jsx)("div",{className:"mb-4 flex items-end justify-end",children:(0,s.jsx)(i.$,{variant:"outline",size:"icon_sm",onClick:()=>eW(!eP),"data-sentry-element":"Button","data-sentry-source-file":"OffenseDetailModal.tsx",children:eP?"Show JSON":"Show Table"})}),(0,s.jsx)("div",{className:"max-w-full min-w-0 font-mono text-xs break-words whitespace-pre-wrap",style:{overflowWrap:"anywhere",wordBreak:"break-word"},children:eh?"Loading...":eP?(T=ec.jsonData)&&"object"==typeof T?(0,s.jsxs)("table",{className:"w-full table-fixed border-collapse border border-[var(--primary)] text-sm text-white","data-sentry-component":"renderJsonAsTable","data-sentry-source-file":"OffenseDetailModal.tsx",children:[(0,s.jsx)("thead",{className:"",children:(0,s.jsxs)("tr",{className:"bg-[var(--primary)] text-left",children:[(0,s.jsx)("th",{className:"w-1/3 border border-[var(--primary)] px-2 py-1",children:"Key"}),(0,s.jsx)("th",{className:"w-2/3 border border-[var(--primary)] px-2 py-1",children:"Value"})]})}),(0,s.jsx)("tbody",{children:Object.entries(T).map(e=>{let[t,a]=e;return(0,s.jsxs)("tr",{className:"odd:bg-card even:bg-muted/20",children:[(0,s.jsx)("td",{className:"border border-[var(--primary)] px-2 py-1 font-semibold break-words text-green-400",children:t}),(0,s.jsx)("td",{className:"border border-[var(--primary)] px-2 py-1 break-words whitespace-pre-wrap",children:"object"==typeof a&&null!==a?JSON.stringify(a,null,2):String(a)})]},t)})})]}):null:eo(ec.jsonData)})]}),(0,s.jsx)(m.av,{value:"timeline",className:"bg-card rounded-lg px-4 py-4","data-sentry-element":"TabsContent","data-sentry-source-file":"OffenseDetailModal.tsx",children:(0,s.jsx)("div",{className:"border-primary/60 relative space-y-6 border-l-2 pl-6",children:(()=>{let e=(()=>{let e=[],t=(t,a,s,r)=>{t&&e.push({stage:a,time:t,desc:s||void 0,by:null==r?void 0:r.by,isComment:null==r?void 0:r.isComment})};return t(ec.createdAt,"Created".concat((null==ec?void 0:ec.tenantName)?" for ".concat(ec.tenantName):""),null==ec?void 0:ec.description),t(ec.assignedAt,"Assigned to ".concat((null==ec?void 0:ec.assignedToName)||"Unknown"),(null==ec?void 0:ec.assignedByName)?"Assigned by ".concat(ec.assignedByName):void 0),t(ec.escalatedAt,"Escalated by ".concat((null==ec?void 0:ec.escalatedByName)||"Unknown")),(Array.isArray(null==ec?void 0:ec.comments)?ec.comments:[]).forEach(e=>{let a=(null==e?void 0:e.commentedAt)||(null==e?void 0:e.commented_at)||(null==e?void 0:e.createdAt)||(null==e?void 0:e.created_at)||null,s=(null==e?void 0:e.updatedAt)||(null==e?void 0:e.updated_at)||null,r=(null==e?void 0:e.updatedBy)||(null==e?void 0:e.updated_by)||null,n=String((null==e?void 0:e.comment)||"").trim(),l=(null==e?void 0:e.commentedByName)||(null==e?void 0:e.commented_by_name)||"Unknown",i=(null==e?void 0:e.updatedByName)||(null==e?void 0:e.updated_by_name)||l,o=!!((null==e?void 0:e.parentComment)||(null==e?void 0:e.parent_comment));r&&s?t(s,"Comment updated by ".concat(i),n||void 0,{isComment:!0}):t(a,o?"Replied by ".concat(l):"Commented by ".concat(l),n||void 0,{isComment:!0})}),t(ec.reviewedAt,"Reviewed by ".concat((null==ec?void 0:ec.reviewedByName)||"Unknown")),t(ec.casedAt,"Case created by ".concat((null==ec?void 0:ec.casedByName)||"Unknown")),t(ec.closedAt,"Closed by ".concat((null==ec?void 0:ec.closedByName)||"Unknown")),t(ec.reopenedAt,"Reopened by ".concat((null==ec?void 0:ec.reopenedByName)||"Unknown")),t(ec.reclosedAt,"Reclosed by ".concat((null==ec?void 0:ec.reclosedByName)||"Unknown")),e.sort((e,t)=>
1new Date(e.time).getTime()-new Date(t.time).getTime())})();return 0===e.length?(0,s.jsx)("p",{className:"text-center text-gray-500",children:"No events to display"}):e.map((e,t)=>{let a=e.desc;if(e.isComment&&e.desc){let t=e.desc.replace(/\s+/g," ").trim();a=t.length>160?"".concat(t.slice(0,160).trimEnd(),"..."):t}return(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("div",{className:"bg-primary border-card absolute top-1 -left-[33px] h-4 w-4 rounded-full border-2"}),(0,s.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,s.jsx)("p",{className:"text-sm font-semibold text-white",children:e.stage}),e.by&&(0,s.jsxs)("p",{className:"text-xs text-gray-400",children:["by ",e.by]}),a&&(e.isComment?(0,s.jsx)("p",{className:"border-primary/40 mt-1 border-l-2 pl-2 text-xs text-gray-300 italic",children:a}):(0,s.jsx)("p",{className:"line-clamp-2 text-xs text-gray-400",children:a})),(0,s.jsx)("p",{className:"mt-0.5 text-[11px] text-gray-500",children:ez(e.time)})]})]},t)})})()})})]})})]}),(0,s.jsx)(I.A,{open:eS,onOpenChange:eA,offenseId:(null==ec?void 0:ec.id)||null,requestedTenant:null==ec?void 0:ec.tenant,onSuccess:async()=>{await eb(),B&&await B()},"data-sentry-element":"AssignModal","data-sentry-source-file":"OffenseDetailModal.tsx"}),(0,s.jsx)($,{open:em,onOpenChange:ef,offense:{id:null==ec?void 0:ec.id,tenant:null==ec?void 0:ec.tenant,alertId:null==ec?void 0:ec.alertId,severity:null==ec?void 0:ec.severity,description:null==ec?void 0:ec.description,title:null==ec||null==(u=ec.jsonData)?void 0:u.title,offenseSource:null==ec?void 0:ec.offenseSource,tenantName:null==ec?void 0:ec.tenantName,siemSource:null==ec?void 0:ec.siemSource,investigation:null==ec?void 0:ec.investigation},onInvestigationSaved:async()=>{await eb(),B&&await B()},"data-sentry-element":"AskDexterModal","data-sentry-source-file":"OffenseDetailModal.tsx"}),(0,s.jsx)(X.A,{open:eR,setOpen:eL,offenseIds:[ec.id],requestedTenant:(null==ec?void 0:ec.tenant)?[String(ec.tenant)]:[],onSuccess:async()=>{await eb(),B&&await B()},"data-sentry-element":"CloseModal","data-sentry-source-file":"OffenseDetailModal.tsx"}),(0,s.jsx)(Q.A,{open:eU,setOpen:eB,offenseIds:[ec.id],requestedTenant:(null==ec?void 0:ec.tenant)?[String(ec.tenant)]:[],onSuccess:async()=>{await eb(),B&&await B()},"data-sentry-element":"LinkToCaseModal","data-sentry-source-file":"OffenseDetailModal.tsx"}),(0,s.jsx)(Z.Ay,{open:eq,setOpen:eJ,caseId:(null==ec?void 0:ec.caseId)||null,tenantId:(null==ec?void 0:ec.tenant)||null,onOpenOffense:()=>{eJ(!1)},"data-sentry-element":"CaseDetailsModal","data-sentry-source-file":"OffenseDetailModal.tsx"}),(0,s.jsx)(H.Ay,{open:e_,setOpen:e=>{eC(e),e||(eF(!1),ek(!1))},editMode:eE,caseId:eE&&eD||void 0,caseStatus:eE?"Draft":void 0,tenantId:(null==ec?void 0:ec.tenant)||null,offenseId:(null==ec?void 0:ec.id)||null,dexterOffense:{id:null==ec?void 0:ec.id,alertId:null==ec?void 0:ec.alertId,severity:null==ec?void 0:ec.severity,description:null==ec?void 0:ec.description,title:null==ec||null==(k=ec.jsonData)?void 0:k.title,offenseSource:null==ec?void 0:ec.offenseSource,siemSource:null==ec?void 0:ec.siemSource},dexterInvestigation:null==ec?void 0:ec.investigation,dexterAutoDraft:eI,allowOffenseCaseActions:!0,onSuccess:async e=>{if(eC(!1),eF(!1),(null==e?void 0:e.mode)==="draft"){await eb(),B&&await B();return}await eb(),B&&await B()},"data-sentry-element":"CreateCaseModal","data-sentry-source-file":"OffenseDetailModal.tsx"})]})}},59816:(e,t,a)=>{a.d(t,{S:()=>r,U:()=>n});var s=a(28067);let r={root:{children:[{children:[],direction:"ltr",format:"",indent:0,type:"paragraph",version:1}],direction:"ltr",format:"",indent:0,type:"root",version:1}},n=e=>{try{if(!e)return r;if("object"==typeof e&&(null==e?void 0:e.root))return e;let t=Array.isArray(e)?e.filter(Boolean).join("\n"):String(e),a=t.trim();if(!a)return r;if(a.startsWith("{"))try{let e=JSON.parse(a);if(e&&"object"==typeof e&&(null==e?void 0:e.root))return e}catch(e){}if(/[<][a-z][\s\S]*>/i.test(a))return(0,s.t)(a);return{root:{children:t.split(/\r?\n/).map(e=>({children:e?[{detail:0,format:0,mode:"normal",style:"",text:e,type:"text",version:1}]:[],direction:"ltr",format:"",indent:0,type:"paragraph",version:1})),direction:"ltr",format:"",indent:0,type:"root",version:1}}}catch(e){return r}}},65250:(e,t,a)=>{a.d(t,{Fc:()=>i,Qg:()=>l,WT:()=>d,Y3:()=>
1o});var s=a(85218),r=a(34686);let n=e=>e?(0,r.jN)(e):[],l=async function(){var e,t,a,n;let l=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;try{let a=Object.fromEntries(Object.entries(l).filter(e=>{let[,t]=e;return null!=t&&("string"!=typeof t||""!==t.trim())&&(Array.isArray(t)?t.length>0:"object"!=typeof t||Object.keys(t).length>0)})),n={...i},{user:o,requestedTenant:d,fieldSearch:c}=i,u=o?(0,r.jN)(o):null==d?[]:Array.isArray(d)?d.filter(e=>"string"==typeof e&&""!==e.trim()):[d];if(c){let e={...c};Array.isArray(e.filters)&&(e.filters=e.filters.filter(e=>e&&"string"==typeof e.fieldName&&""!==e.fieldName.trim()&&Array.isArray(e.value)&&e.value.length>0&&"string"==typeof e.operator&&""!==e.operator.trim()),e.filters.length||delete e.filters),e.filters||e.logicalOperator?n.fieldSearch=e:n.fieldSearch=void 0}let m={requestedTenant:u,...n.fieldSearch?{fieldSearch:n.fieldSearch}:{}},f=await s.A.post("/case-management/caseTactics/list",m,{params:a}),p=null!=(t=null==f||null==(e=f.data)?void 0:e.data)?t:null==f?void 0:f.data;if(p&&"object"==typeof p&&"success"in p)return p;return{success:!0,data:p}}catch(e){return{success:!1,message:(null==e||null==(n=e.response)||null==(a=n.data)?void 0:a.message)||"Failed to fetch tactics"}}},i=async(e,t)=>{try{let a=n(t);return(await s.A.post("/case-management/caseTactics/create",{tacticName:e.tacticName,requestedTenant:a})).data}catch(e){var a,r;return{success:!1,message:(null==e||null==(r=e.response)||null==(a=r.data)?void 0:a.message)||"Failed to create tactic"}}},o=async(e,t,a)=>{try{let r=n(a);return(await s.A.patch("/case-management/caseTactics/update/".concat(e),{tacticName:t.tacticName,requestedTenant:r})).data}catch(e){var r,l;return{success:!1,message:(null==e||null==(l=e.response)||null==(r=l.data)?void 0:r.message)||"Failed to update tactic"}}},d=async(e,t)=>{try{let a=n(t);return(await s.A.patch("/case-management/caseTactics/disable/".concat(e),{requestedTenant:a})).data}catch(e){var a,r;return{success:!1,message:(null==e||null==(r=e.response)||null==(a=r.data)?void 0:a.message)||"Failed to delete tactic"}}}},68160:(e,t,a)=>{a.d(t,{Q8:()=>c,LR:()=>g,R$:()=>v,iB:()=>o,Rm:()=>d,vx:()=>f,SP:()=>u});var s=a(83225),r=a(21338),n=a(66609);let l=r.A.create({baseURL:"https://platform.socbyte.ai/api/integrations"});l.interceptors.request.use(e=>{e.withCredentials=!0;try{{let t=localStorage.getItem("sb:lastActivityAtMs"),a=t?Number(t):NaN;Number.isFinite(a)&&Date.now()-a<15e3&&(e.headers=e.headers||{},e.headers["X-SB-User-Active"]="1")}}catch(e){}return e});let i=async()=>{try{await (0,s.ri)()}catch(e){console.error("Logout API failed",e)}try{document.cookie="sb_auth=; Path=/; Max-Age=0; SameSite=Lax"}catch(e){}try{localStorage.setItem("sb:logoutAtMs",String(Date.now()))}catch(e){}(0,s.F8)(),window.location.href="/login"};l.interceptors.response.use(e=>e,e=>{var t,a,s,r;return(null==(t=e.response)?void 0:t.status)===403?n.oR.error(null==(r=e.response)||null==(s=r.data)?void 0:s.message):(null==(a=e.response)?void 0:a.status)===401&&i(),Promise.reject(e)});let o=async function(){var e,t,a,s,r,n,i,o;let d=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{let i={};void 0!==d.page&&null!==d.page&&(i.page=Number(d.page)),void 0!==d.size&&null!==d.size&&(i.limit=d.size),d.search&&(i.search=d.search),(null==(e=
1d.startDate)?void 0:e.trim())&&(i.startDate=d.startDate.trim()),(null==(t=d.endDate)?void 0:t.trim())&&(i.endDate=d.endDate.trim()),void 0!==d.enabled&&(i.enabled=String(d.enabled));let o={...c};if(null==(a=o.fieldSearch)?void 0:a.filters){let e=o.fieldSearch.filters.filter(e=>{var t,a;return(null==e||null==(t=e.fieldName)?void 0:t.trim())&&(null==e||null==(a=e.operator)?void 0:a.trim())&&Array.isArray(e.value)&&e.value.length>0});0===e.length?delete o.fieldSearch:o.fieldSearch={...o.fieldSearch,filters:e}}let u=(await l.post("integrations/list",o,{params:i})).data,m=null==u?void 0:u.data,f=null!=(r=null!=(s=null==m?void 0:m.integrations)?s:null==m?void 0:m.items)?r:[],p=(Array.isArray(f)?f:[]).map(e=>(function(e){let t=e.tool,a=!0===e.enabled||"true"===e.enabled||1===e.enabled||"t"===e.enabled,s=null!=e.display_name?String(e.display_name):"",r=null!=e.platform?String(e.platform):(null==t?void 0:t.provider_key)!=null?String(t.provider_key):"",n=(null==t?void 0:t.display_name)!=null&&""!==String(t.display_name).trim()?String(t.display_name):(null==t?void 0:t.name)!=null&&""!==String(t.name).trim()?String(t.name):"";return{id:String(e.id),tenant_id:String(e.tenant_id),tool_id:String(e.tool_id),tool_name:n||s||r,platform:r||null,provider_key:r||(null==t?void 0:t.provider_key)||(null==t?void 0:t.name)||null,catalog_name:(null==t?void 0:t.name)!=null&&""!==String(t.name).trim()?String(t.name):null,base_url:null!=e.base_url?String(e.base_url):null,threat_hunting_url:null!=e.console_url?String(e.console_url):null,client_id:null,client_secret:null,api_key:null,collector_url:null!=e.console_url?String(e.console_url):null,user_name:null,password:null,organization_id:null!=e.tenant_ref?String(e.tenant_ref):null,version:null!=e.version?String(e.version):null,offense_source:null!=e.offense_source&&""!==String(e.offense_source).trim()?String(e.offense_source):null,deep_link_template:null!=e.deep_link_template&&""!==String(e.deep_link_template).trim()?String(e.deep_link_template):null,ingestion_mode:"email"===e.ingestion_mode?"email":"api",mail_config:e.mail_config&&"object"==typeof e.mail_config?e.mail_config:null,status:a?"enabled":"disabled",location:null!=e.location&&""!==String(e.location).trim()?String(e.location):null,tenant_name:null!=e.tenant_name&&""!==String(e.tenant_name).trim()?String(e.tenant_name):null,created_at:null!=e.created_at?String(e.created_at):null,updated_at:null!=e.updated_at?String(e.updated_at):null}})(e));return{...u,success:!1!==u.success,data:{integrations:p,total:null!=(n=null==m?void 0:m.total)?n:0}}}catch(e){return{success:!1,message:(null==e||null==(o=e.response)||null==(i=o.data)?void 0:i.message)||"Failed to fetch integrations",errorList:[e]}}},d=async function(){var e,t,a,s,r,n;let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{let r={};return void 0!==i.page&&null!==i.page&&(r.page=Number(i.page)),void 0!==i.size&&null!==i.size&&(r.limit=i.size),i.search&&(r.search=i.search),(null==(e=i.startDate)?void 0:e.trim())&&(r.startDate=i.startDate.trim()),(null==(t=i.endDate)?void 0:t.trim())&&(r.endDate=i.endDate.trim()),(null==(a=i.fieldSearch)?void 0:a.filters)&&i.fieldSearch.filters.length>0&&(r.filters=JSON.stringify(i.fieldSearch.filters),r.logicalOperator=null!=(s=i.fieldSearch.logicalOperator)?s:"AND"),(await l.get("third-party-tools",{params:r})).data}catch(e){return{success:!1,message:(null==e||null==(n=e.response)||null==(r=n.data)?void 0:r.message)||"Failed to fetch third party tools",errorList:[e]}}},c=async e=>{var t,a,s,r,n;try{let{requestedTenant:r,tool_name:n,...i}=e,o=null==r?void 0:r[0],d={...Object.fromEntries(Object.entries(i).filter(e=>{let[,t]=e;return null!=t&&("string"!=typeof t||""!==t.trim())&&(Array.isArray(t)?t.length>0:"object"!=typeof t||Object.keys(t).length>0)})),tenant_id:o,display_name:n,auth_type:i.client_id?"oauth2":i.api_key?"api_key":"basic",location:null!=(s=i.location)?s:"cloud",credentials:{}};i.threat_hunting_url&&(d.console_url=i.threat_hunting_url),i.collector_url&&(d.console_url=i.collector_url),i.organization_id&&(d.tenant_ref=i.organization_id);let c=null==(t=i.version)?void 0:t.trim();return c?d.version=c:delete d.version,i.status&&(d.enabled="enabled"===i.status),(null==(a=i.deep_link_template)?void 0:a.trim())&&(d.deep_link_type="template"),delete d.threat_hunting_url,delete d.collector_url,delete d.organization_id,delete d.status,i.api_key&&(d.credentials.api_key=i.api_key),i.user_name&&(d.credentials.username=i.user_name),i.password&&(d.credentials.password=i.password),i.client_id&&(d.credentials.client_id=i.client_id),i.client_secret&&(d.credentials.client_secret=i.client_secret),i.mail_password&&(d.credentials.mail_password=i.mail_password),i.mail_client_secret&&(d.credentials.mail_client_secret=i.mail_client_secret),i.ingestion_mode&&(d.ingestion_mode=i.ingestion_mode),"email"===i.ingestion_mode&&i.mail_config?d.mail_config=i.mail_config:delete d.mail_config,delete d.mail_password,delete d.mail_client_secret,delete d.api_key,delete d.user_name,delete d.password,delete d.client_id,delete d.client_secret,(await l.post("integrations",d)).data}catch(e){return{success:!1,message:(null==e||null==(n=e.response)||null==(r=n.data)?void 0:r.message)||"Failed to add integration",errorList:[e]}}},u=async e=>{var t,a,s;try{let{requestedTenant:a,integration_id:s,tool_name:r,tool_id:n,...i}=e,o={display_name:r,credentials:{}};if(i.base_url&&(o.base_url=i.base_url),void 0!==i.offense_source&&(o.offense_source=i.offense_source.trim()||null),i.location&&(o.location=i.location),void 0!==i.deep_link_template){let e=i.deep_link_template.trim();o.deep_link_template=e||null,o.deep_link_type=e?"template":"none"}return i.threat_hunting_url&&(o.console_url=i.threat_hunting_url),i.collector_url&&(o.console_url=i.collector_url),i.organization_id&&(o.tenant_ref=i.organization_id),void 0!==i.version&&(o.version=(null==(t=i.version)?void 0:t.trim())||null),i.status&&(o.enabled="enabled"===i.status),i.api_key&&(o.credentials.api_key=i.api_key),i.user_name&&(o.credentials.username=i.user_name),i.password&&(o.credentials.password=i.password),i.client_id&&(o.credentials.client_id=i.client_id),i.client_secret&&(o.credentials.client_secret=i.client_secret),i.mail_password&&(o.credentials.mail_password=i.mail_password),i.mail_client_secret&&(o.credentials.mail_client_secret=i.mail_client_secret),void 0!==i.ingestion_mode&&(o.ingestion_mode=i.ingestion_mode),void 0!==i.mail_config&&(o.mail_config=i.mail_config),0===Object.keys(o.credentials).length&&delete o.credentials,(await l.patch("integrations/".concat(s),o)).data}catch(e){return{success:!1,message:(null==e||null==(s=e.response)||null==(a=s.data)?void 0:a.message)||"Failed to update integration",errorList:[e]}}},m={url:null,type:"none",native_field:null,integration_id:null,integration_name:null},f=async(e,t,a)=>{if(!(null==e?void 0:e.trim())||!(null==t?void 0:t.trim())||!(null==a?void 0:a.trim()))return m;try{var s;let r=null==(s=(await l.get("integrations/deep-link",{params:{siem_source:e.trim(),offense_id:t.trim(),tenant_id:a.trim(),requestedTenant:a.trim()}})).data)?void 0:s.data;return null!=r?r:m}catch(e){return m}},p=async(e,t)=>{try{return(await l.post("soar/actions/execute",{integration_id:e,action:t})).data}catch(e){var a,s;return{success:!1,message:(null==e||null==(s=e.response)||null==(a=s.data)?void 0:a.message)||"Failed to execute SOAR action",errorList:[e]}}},v=async e=>{var t,a;let s=await p(e,{type:"splunk_list_saved_searches"});if((null==s?void 0:s.success)===!1)return{success:!1,message:(null==s?void 0:s.message)||"Failed to fetch Splunk saved searches",savedSearches:[]};let r=null!=(t=null==s?void 0:s.data)?t:s;return{success:!0,savedSearches:null!=(a=null==r?void 0:r.savedSearches)?a:[]}},g=async e=>{try{return(await l.post("integrations/delete",{ids:e})).data}catch(e){var t,a;return{success:!1,message:(null==e||null==(a=e.response)||null==(t=a.data)?void 0:t.message)||"Failed to delete integration(s)",errorList:[e]}}}},73470:(e,t,a)=>{a.d(t,{A6:()=>o,YS:()=>i,dy:()=>n,lO:()=>l});var s=a(85218),r=a(34686);let n=async function(){var e,t,a,n;let l=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;try{let a=Object.fromEntries(Object.entries(l).filter(e=>{let[,t]=e;return null!=t&&("string"!=typeof t||""!==t.trim())&&(Array.isArray(t)?t.length>0:"object"!=typeof t||Object.keys(t).length>0)})),n={...i},{user:o,fieldSearch:d,requestedTenant:c,...u}=i,m=null!=c?Array.isArray(c)?c:[c]:o?(0,r.jN)(o):[];if(n.fieldSearch){let e={...n.fieldSearch};Array.isArray(e.filters)&&(e.filters=e.filters.filter(e=>e&&"string"==typeof e.fieldName&&""!==e.fieldName.trim()&&Array.isArray(e.value)&&e.value.length>
10&&"string"==typeof e.operator&&""!==e.operator.trim()),e.filters.length||delete e.filters),e.filters||e.logicalOperator?n.fieldSearch=e:n.fieldSearch=void 0}let f={requestedTenant:m,...n.fieldSearch?{fieldSearch:n.fieldSearch}:{}},p=await s.A.post("/case-management/caseCategory/listWithSubcategories",f,{params:a}),v=null!=(t=null==p||null==(e=p.data)?void 0:e.data)?t:null==p?void 0:p.data;if(v&&"object"==typeof v&&"success"in v)return v;return{success:!0,data:v}}catch(e){return{success:!1,message:(null==e||null==(n=e.response)||null==(a=n.data)?void 0:a.message)||"Failed to fetch case categories"}}},l=async e=>{try{return(await s.A.post("/case-management/caseSubCategory/create",e)).data}catch(e){var t,a;return{success:!1,message:(null==e||null==(a=e.response)||null==(t=a.data)?void 0:t.message)||"Failed to create subcategory"}}},i=async(e,t)=>{try{return(await s.A.patch("/case-management/caseSubCategory/update/".concat(e),t)).data}catch(e){var a,r;return{success:!1,message:(null==e||null==(r=e.response)||null==(a=r.data)?void 0:a.message)||"Failed to update subcategory"}}},o=async(e,t)=>{try{let{user:a,fieldSearch:n,requestedTenant:l,...i}=t,o=null!=l?Array.isArray(l)?l:[l]:a?(0,r.jN)(a):[];return(await s.A.post("/case-management/caseSubCategory/list/".concat(e),{requestedTenant:o})).data}catch(e){var a,n;return{success:!1,message:(null==e||null==(n=e.response)||null==(a=n.data)?void 0:a.message)||"Failed to fetch subcategories"}}}},83915:(e,t,a)=>{a.d(t,{A:()=>p});var s=a(95155),r=a(12115),n=a(37911),l=a(20363),i=a(25475),o=a(70747),d=a(30519),c=a(22980),u=a(87020),m=a(31376);function f(e){let{open:t,onOpenChange:a,offenseId:f,offenseTargets:p,requestedTenant:v,onSuccess:g}=e,{user:x}=(0,c.J)(),[y,h]=r.useState([]),[b,j]=r.useState(""),[w,N]=r.useState(!1),S=r.useMemo(()=>Array.isArray(p)&&p.length>0?p.map(e=>({id:String(e.id||"").trim(),tenant:e.tenant?String(e.tenant):void 0})).filter(e=>!!e.id):f?[{id:String(f),tenant:Array.isArray(v)?String(v[0]||""):v?String(v):void 0}]:[],[f,p,v]),A=r.useCallback(async()=>{try{var e,t;N(!0);let a=Array.isArray(v)?v.filter(Boolean).map(String):v?[String(v)]:(null==(e=S[0])?void 0:e.tenant)?[S[0].tenant]:[],s=await (0,d.sU)({user:x,requestedTenant:a,includeAllocatedTenantUsers:!0,excludePendingUsers:!0,excludeTrainingUsers:!0}),r=((null==s||null==(t=s.data)?void 0:t.results)||[]).filter(e=>{var t,a;let s=String((null==e?void 0:e.status)||"").toLowerCase();if("pending"===s)return!1;let r=String((null==e?void 0:e.roleName)||(null==e?void 0:e.role_name)||"").toLowerCase();if("training"===r)return!1;let n=null!=(a=null!=(t=null==e?void 0:e.isActive)?t:null==e?void 0:e.is_active)?a:null;return!1!==n&&0!==n}).map(e=>({id:(null==e?void 0:e.id)||(null==e?void 0:e.userId)||(null==e?void 0:e._id)||(null==e?void 0:e.user_id),email:(null==e?void 0:e.email)||(null==e?void 0:e.userEmail)||(null==e?void 0:e.username)||""})).filter(e=>!!(null==e?void 0:e.id)),n=String((null==x?void 0:x.userId)||(null==x?void 0:x.id)||"");h(r.filter(e=>n&&String(e.id)!==n))}catch(e){h([])}finally{N(!1)}},[v,S,x,null==x?void 0:x.userId,null==x?void 0:x.id]);r.useEffect(()=>{t&&(j(""),A())},[t,A]);let _=async()=>{if(!b)return void m.toast.error("Please select a user");if(0===S.length)return void m.toast.error("No offense selected");try{var e,t,s,r,n;let l=Array.from(new Set(S.map(e=>e.id))),i=Array.from(new Set(S.map(e=>String(e.tenant||"").trim()).filter(Boolean).concat(Array.isArray(v)?v.filter(Boolean).map(String):v?[String(v)]:[]))),o=await (0,u.cD)(l,b,i),d=null!=(s=null==o||null==(e=o.data)?void 0:e.successCount)?s:(null==o?void 0:o.success)?l.length:0,c=null!=(r=null==o||null==(t=o.data)?void 0:t.failedCount)?r:(null==o?void 0:o.success)?0:l.length;if(d>0){m.toast.success(c>0?"Assigned ".concat(d," offense(s). ").concat(c," failed."):"Assigned ".concat(d," offense(s)."));let e=((null==o||null==(n=o.data)?void 0:n.results)||[]).find(e=>!e.success);(null==e?void 0:e.message)&&m.toast.error(e.message),a(!1),j(""),g&&g()}else m.toast.error((null==o?void 0:o.message)||"You do not have permission to assign offenses.")}catch(e){m.toast.error((null==e?void 0:e.message)||"You do not have permission to assign offenses.")}};return(0,s.jsx)(n.a,{heading:"Assign to User",open:t,onOpenChange:a,className:"w-full max-w-md","data-sentry-element":"Modal","data-sentry-component":"AssignModalComponent","data-sentry-source-file":"AssignModal.tsx",children:(0,s.jsxs)("div",{className:"space-y-4 p-2",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(l.J,{"data-sentry-element":"Label","data-sentry-source-file":"AssignModal.tsx",children:"Select User"}),(0,s.jsxs)(i.l6,{value:b,onValueChange:j,disabled:w,"data-sentry-element":"Select","data-sentry-source-file":"AssignModal.tsx",children:[(0,s.jsx)(i.bq,{className:"w-full","data-sentry-element":"SelectTrigger","data-sentry-source-file":"AssignModal.tsx",children:(0,s.jsx)(i.yv,{placeholder:w?"Loading...":"Choose a user","data-sentry-element":"SelectValue","data-sentry-source-file":"AssignModal.tsx"})}),(0,s.jsx)(i.gC,{"data-sentry-element":"SelectContent","data-sentry-source-file":"AssignModal.tsx",children:y.map(e=>(0,s.jsx)(i.eb,{value:String(e.id),children:e.email||e.id},e.id))})]})]}),(0,s.jsx)("div",{className:"flex justify-end gap-2",children:(0,s.jsxs)(o.$,{onClick:_,disabled:!b||0===S.length,"data-sentry-element":"Button","data-sentry-source-file":"AssignModal.tsx",children:["Assign",S.length>1?" (".concat(S.length,")"):""]})})]})})}let p=e=>(0,s.jsx)(f,{...e,"data-sentry-element":"AssignModalComponent","data-sentry-component":"AssignModal","data-sentry-source-file":"AssignModal.tsx"})},87020:(e,t,a)=>{a.d(t,{Gu:()=>f,cD:()=>p,Ip:()=>g,E4:()=>j,gC:()=>b,qT:()=>c,Lt:()=>i,RT:()=>l,cE:()=>d,VN:()=>y,p3:()=>x,Q6:()=>v,Vk:()=>o,bG:()=>w}),a(83225);let s=a(21338).A.create({baseURL:"https://platform.socbyte.ai/api/siem"});s.interceptors.request.use(e=>{e.withCredentials=!0;try{{let t=localStorage.getItem("sb:lastActivityAtMs"),a=t?Number(t):NaN;Number.isFinite(a)&&Date.now()-a<15e3&&(e.headers=e.headers||{},e.headers["X-SB-User-Active"]="1")}}catch(e){}return e}),s.interceptors.response.use(e=>e,e=>Promise.reject(e));let r=e=>null!=e&&("string"!=typeof e||""!==e.trim())&&(Array.isArray(e)?e.length>0:"object"!=typeof e||Object.keys(e).length>0),n=e=>{let{requestedTenant:t,fieldSearch:a,filters:s,logicalOperator:n,...l}=Object.fromEntries(Object.entries(e).filter(e=>{let[,t]=e;return r(t)})),i={requestedTenant:null==t?["all"]:Array.isArray(t)?t.length>0?t.filter(e=>"string"==typeof e&&""!==e.trim()):["all"]:[t]};return a&&"object"==typeof a?i.fieldSearch=a:s&&Array.isArray(s)&&(i.fieldSearch={filters:s,logicalOperator:null!=n?n:"AND"}),{body:i,queryParams:Object.fromEntries(Object.entries(l).filter(e=>{let[,t]=e;return r(t)}))}},l=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{let{body:t,queryParams:a}=n(e);
1return(await s.post("/SIEM/offense/list",t,{params:a})).data}catch(e){var t,a;return{success:!1,message:(null==e||null==(a=e.response)||null==(t=a.data)?void 0:t.message)||"Failed to fetch offenses"}}},i=async e=>{try{let{clubId:t,headerId:a,...r}=e,{body:l,queryParams:i}=n(r);return l.clubId=t,a&&(l.headerId=a),(await s.post("/SIEM/offense/list/group-members",l,{params:i})).data}catch(e){var t,a;return{success:!1,message:(null==e||null==(a=e.response)||null==(t=a.data)?void 0:t.message)||"Failed to fetch grouped offenses"}}},o=async(e,t)=>{try{return(await s.post("/SIEM/userConfig/user-config/".concat(e),t)).data}catch(e){var a,r;return{success:!1,message:(null==e||null==(r=e.response)||null==(a=r.data)?void 0:a.message)||"Failed to save user configuration"}}},d=async e=>{try{return(await s.get("/SIEM/userConfig/user-config/".concat(e))).data}catch(e){var t,a;return{success:!1,message:(null==e||null==(a=e.response)||null==(t=a.data)?void 0:t.message)||"Failed to fetch user configuration"}}},c=async(e,t)=>{try{let a={};
1return void 0!==t&&(a.requestedTenant=t),await s.get("/SIEM/offense/view/".concat(e),{params:a})}catch(e){var a,r;return{success:!1,message:(null==e||null==(r=e.response)||null==(a=r.data)?void 0:a.message)||"Failed to fetch offense detail"}}},u=(e,t)=>{var a,s,r;if((null==e||null==(a=e.response)?void 0:a.status)===403)return"You do not have permission to assign offense(s).";let n=null==e||null==(r=e.response)||null==(s=r.data)?void 0:s.message;return n&&"string"==typeof n&&!/^403\s+forbidden/i.test(n.trim())?n:t},m=(e,t)=>({...e,...t&&t.length>0?{requestedTenant:t}:{}}),f=async(e,t)=>{try{return(await s.post("/SIEM/offense/assign/me",m({ids:e},t))).data}catch(e){var a,r;return{success:!1,message:u(e,"Failed to assign offense(s) to me"),data:null==e||null==(r=e.response)||null==(a=r.data)?void 0:a.data}}},p=async(e,t,a)=>{try{return(await s.post("/SIEM/offense/assign/other",m({ids:e,assigned_to:t},a))).data}catch(e){var r,n;return{success:!1,message:u(e,"Failed to assign offense(s) to user"),data:null==e||null==(n=e.response)||null==(r=n.data)?void 0:r.data}}},v=async(e,t)=>{try{return(await s.post("/SIEM/offense/review",m({ids:e},t))).data}catch(e){var a,r;return{success:!1,message:h(e,"Failed to review offense(s)"),data:null==e||null==(r=e.response)||null==(a=r.data)?void 0:a.data}}},g=async(e,t,a)=>{try{return(await s.post("/SIEM/offense/close",m({ids:e,disposition:t},a))).data}catch(e){var r,n;return{success:!1,message:h(e,"Failed to close offense(s)"),data:null==e||null==(n=e.response)||null==(r=n.data)?void 0:r.data}}},x=async(e,t)=>{try{return(await s.post("/SIEM/offense/reopen",m({ids:e},t))).data}catch(e){var a,r;return{success:!1,message:h(e,"Failed to reopen offense(s)"),data:null==e||null==(r=e.response)||null==(a=r.data)?void 0:a.data}}},y=async(e,t,a)=>{try{return(await s.post("/SIEM/offense/link-case",{offenseIds:e,referenceId:t,...a&&a.length>0?{requestedTenant:a}:{}})).data}catch(e){var r,n,l,i,o,d,c,u,m;return{success:!1,message:(null==e||null==(r=e.response)?void 0:r.status)===403?"You do not have permission to link offense(s) to a case.":(null==e||null==(l=e.response)||null==(n=l.data)?void 0:n.message)||(null==e||null==(c=e.response)||null==(d=c.data)||null==(o=d.errorList)||null==(i=o[0])?void 0:i.message)||"Failed to link offense(s) to the case",data:null==e||null==(m=e.response)||null==(u=m.data)?void 0:u.data}}},h=(e,t)=>{var a,s,r;let n=null==e||null==(a=e.response)?void 0:a.data,l=null==n||null==(r=n.errorList)||null==(s=r[0])?void 0:s.message,i=(null==n?void 0:n.message)||l;return i&&"string"==typeof i&&i.trim()?i.trim():t},b=async(e,t)=>
1{try{return(await s.post("/SIEM/offense/escalate",m({ids:e},t))).data}catch(e){var a,r;return{success:!1,message:h(e,"Failed to escalate offense(s)"),data:null==e||null==(r=e.response)||null==(a=r.data)?void 0:a.data}}},j=async e=>{try{let t=e=>!!e&&"object"==typeof e&&"function"==typeof e.arrayBuffer&&"number"==typeof e.size,a=new FormData;for(let s of(a.append("ids",JSON.stringify(e.ids||[])),e.parentComment&&a.append("parentComment",e.parentComment),a.append("comment",e.comment),Array.isArray(e.requestedTenant)&&e.requestedTenant.forEach(e=>a.append("requestedTenant",e)),(e=>e?Array.isArray(e)?e.filter(t):t(e)?[e]:[]:[])(e.commented_image_url)))a.append("commented_image_url",s);return(await s.post("/SIEM/offenseComment/create",a)).data}catch(e){var t,a;return{success:!1,message:h(e,"Failed to comment on offense(s)"),data:null==e||null==(a=e.response)||null==(t=a.data)?void 0:t.data}}},w=async(e,t)=>{try{let a=e=>!!e&&"object"==typeof e&&"function"==typeof e.arrayBuffer&&"number"==typeof e.size,r=(e=>e?Array.isArray(e)?e.filter(a):a(e)?[e]:[]:[])(t.commented_image_url);if(r.length>0){let a=new FormData;for(let e of(a.append("comment",t.comment),Array.isArray(t.existingImageIds)&&a.append("existingImageIds",JSON.stringify(t.existingImageIds)),Array.isArray(t.existingImageUrls)&&a.append("existingImageUrls",JSON.stringify(t.existingImageUrls)),!0===t.removeCommentedImage&&a.append("removeCommentedImage","true"),Array.isArray(t.requestedTenant)&&t.requestedTenant.forEach(e=>a.append("requestedTenant",e)),r))a.append("commented_image_url",e);return(await s.patch("/SIEM/offenseComment/update/".concat(e),a)).data}let n={comment:t.comment,removeCommentedImage:!0===t.removeCommentedImage,requestedTenant:t.requestedTenant};return Array.isArray(t.existingImageIds)&&(n.existingImageIds=t.existingImageIds),Array.isArray(t.existingImageUrls)&&(n.existingImageUrls=t.existingImageUrls),(await s.patch("/SIEM/offenseComment/update/".concat(e),n)).data}catch(e){var a,r;return{success:!1,message:(null==e||null==(r=e.response)||null==(a=r.data)?void 0:a.message)||"Failed to update offense comment"}}}},87136:(e,t,a)=>{a.d(t,{Ay:()=>F});var s=a(95155),r=a(12115),n=a(37911),l=a(20363),i=a(25475),o=a(73344),d=a(83548),c=a(70747),u=a(30069);let m=function(){let{onFields:e,onText:t,onError:a}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[s,n]=r.useState(!1),[l,i]=r.useState({title:"",summary:"",remediation:""}),o=r.useRef(null),d=r.useRef({title:"",summary:"",remediation:""}),c=r.useRef(null),m=r.useRef(null),f=r.useRef({onFields:e,onText:t,onError:a});f.current={onFields:e,onText:t,onError:a};let p=r.useCallback(()=>{c.current&&(clearInterval(c.current),c.current=null),m.current&&(clearTimeout(m.current),m.current=null)},[]),v=r.useCallback(()=>{var e;p(),null==(e=o.current)||e.disconnect(),o.current=null},[p]);return r.useEffect(()=>v,[v]),{draft:r.useCallback(e=>{var t,a,s,r;let l="https://platform.socbyte.ai/api/dexter";if(!l){null==(t=(a=f.current).onError)||t.call(a,"NEXT_PUBLIC_DEXTER is not configured.");return}if(!e.investigation){null==(s=(r=f.current).onError)||s.call(r,"Run a Dexter investigation on this offense first.");return}v();let g={title:"",summary:"",remediation:""};i(g),d.current={...g},n(!0);let x=(()=>{try{let e=new URL(l,window.location.href),t=e.pathname.replace(/\/$/,"");return{origin:e.origin,path:t?"".concat(t,"/socket.io"):"/socket.io"}}catch(e){return{origin:l,path:"/socket.io"}}})(),y=(0,u.io)(x.origin,{withCredentials:!0,path:x.path,transports:["polling","websocket"]});o.current=y,c.current=setInterval(()=>{i({...d.current})},60),m.current=setTimeout(()=>{var e,t;n(!1),v();let a=Object.values(d.current).some(Boolean);null==(e=(t=f.current).onError)||e.call(t,a?"Dexter stopped partway. Review and finish the draft.":"Dexter did not respond. Try again.")},9e4),y.on("connect",()=>{y.emit("execute_case_draft",{tenant_id:e.tenantId,offense:e.offense,investigation:e.investigation,options:e.options})}),y.on("connect_error",()=>{var e,t;n(!1),v(),null==(e=(t=f.current).onError)||e.call(t,"Could not reach Dexter.")}),y.on("case_draft_delta",e=>{let t=null==e?void 0:e.field;(null==e?void 0:e.delta)&&t in d.current&&(d.current[t]+=e.delta)}),y.on("case_draft_result",e=>{var t,a,s,r,l;p();let o={title:null!=(s=null==e?void 0:e.title)?s:d.current.title,summary:null!=(r=null==e?void 0:e.summary)?r:d.current.summary,remediation:null!=(l=null==e?void 0:e.remediation)?l:d.current.remediation};d.current={...o}
1,i(o),Object.keys(o).forEach(e=>{var t,a;o[e]&&(null==(t=(a=f.current).onText)||t.call(a,e,o[e]))}),(null==e?void 0:e.fields)&&(null==(t=(a=f.current).onFields)||t.call(a,e.fields)),n(!1),v()});let h=e=>{var t,a;n(!1),v(),null==(t=(a=f.current).onError)||t.call(a,(null==e?void 0:e.message)||"Dexter couldn't draft this case.")};y.on("case_draft_error",h),y.on("error",h)},[p,v]),drafting:s,streaming:l}};var f=a(59816),p=a(10364),v=a(80069),g=a(49619),x=a(7915),y=a(33210),h=a(5993),b=a(96485),j=a(46468),w=a(99403),N=a(14749),S=a(15915),A=a(22980),_=a(66609),C=a(73470),I=a(65250),k=a(25239),D=a(80415);let M="Only the user who reviewed this offense can close the offense, save a case draft, create a case, or update the case.";function O(e){return e?e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("\\x")?decodeURIComponent(e.replace(/^\\x/,"").replace(/(..)/g,"%$1")):e:""}let T=e=>(null==e?void 0:e.success)===!1||(null==e?void 0:e.hasError)===!0,E={root:{children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"paragraph",version:1}],direction:"ltr",format:"",indent:0,type:"root",version:1}};function F(e){var t,a;let{open:u,setOpen:F,onSuccess:R,editMode:L=!1,caseId:U,tenantId:B,offenseId:q,allowOffenseCaseActions:J=!0,caseStatus:P,dexterOffense:W,dexterInvestigation:z,dexterAutoDraft:G=!1}=e,$=new Set(["jpg","jpeg","jfif","png"]),{user:V}=(0,A.J)(),X=!!q&&!L&&!!B,Q="".concat(u?"open":"closed","-").concat(L?"edit-".concat(null!=U?U:"noid"):"create"),[H,K]=(0,r.useState)([]),[Y,Z]=r.useState(void 0),[ee,et]=r.useState(void 0),[ea,es]=(0,r.useState)([]),[er,en]=r.useState(void 0),[el,ei]=r.useState(void 0),[eo,ed]=(0,r.useState)([]),[ec,eu]=r.useState(void 0),[em,ef]=(0,r.useState)([]),[ep,ev]=r.useState(void 0),[eg,ex]=r.useState(void 0),[ey,eh]=(0,r.useState)([]),[eb,ej]=(0,r.useState)([]),[ew,eN]=(0,r.useState)(E),[eS,eA]=(0,r.useState)(E),[e_,eC]=(0,r.useState)([]),[eI,ek]=(0,r.useState)(null),[eD,eM]=(0,r.useState)(null),eO=e=>{let t=String(e||"").toLowerCase();return"draft"===t||"drafted"===t},eT=L&&(eO(P)||eO(null==eD?void 0:eD.status)),[eE,eF]=(0,r.useState)(void 0),[eR,eL]=(0,r.useState)(!1),[eU,eB]=(0,r.useState)(null),[eq,eJ]=(0,r.useState)({}),[eP,eW]=(0,r.useState)(!1),[ez,eG]=(0,r.useState)([]),[e$,eV]=(0,r.useState)([]),[eX,eQ]=(0,r.useState)([]),[eH,eK]=(0,r.useState)([]),[eY,eZ]=(0,r.useState)(""),[e0,e1]=(0,r.useState)(""),e2=!!(W&&z),{draft:e4,drafting:e5,streaming:e3}=m({onText:(e,t)=>{"title"===e&&e1(t),"summary"===e&&eN((0,f.U)(t)),"remediation"===e&&eA((0,f.U)(t))},onFields:e=>{if(e.category){Z(e.category);let t=H.find(t=>String(null==t?void 0:t.categoryName)===e.category);(null==t?void 0:t.id)&&et(String(t.id))}e.sub_category&&en(e.sub_category),e.severity&&ei(e.severity),e.tactic&&eu(e.tactic),_.oR.success("Dexter drafted this case. Review before saving.")},onError:e=>_.oR.error(e)});r.useEffect(()=>{e5&&e3.title&&(e1(e3.title),eJ(e=>({...e,title:!1})))},[e5,e3.title]);let e6=(0,r.useRef)(!1);(0,r.useEffect)(()=>{if(!u){e6.current=!1;return}G&&e2&&!e6.current&&!e5&&0!==H.length&&0!==eo.length&&(e6.current=!0,e7())},[u,G,e2,H,eo]);let e7=()=>{e4({tenantId:String(eE||B||""),offense:W,investigation:z,options:{categories:H.map(e=>{var t;return String(null!=(t=null==e?void 0:e.categoryName)?t:"")}),subCategories:ea.map(e=>{var t,a;return String(null!=(a=null!=(t=null==e?void 0:e.subCategoryName)?t:null==e?void 0:e.name)?a:"")}),severities:["Critical","High","Medium","Low"],tactics:eo.map(e=>{var t,a;return String(null!=(a=null!=(t=null==e?void 0:e.name)?t:null==e?void 0:e.tacticName)?a:"")})}})},[e8,e9]=(0,r.useState)(q),te=e8||q||void 0,tt=!!te&&!J,[ta,ts]=(0,r.useState)({OpenTableSummary:!1,description:"",additionalSummary:[]}),[tr,tn]=(0,r.useState)(!1),tl=async e=>{if(u){if(!e)return void K([]);try{let s=await (0,S.rX)({},{requestedTenant:[e]});if(s&&!1!==s.success){var t,a;K(null!=(a=null==s||null==(t=s.data)?void 0:t.results)?a:[])}else _.oR.error((null==s?void 0:s.message)||"Failed to fetch categories"),K([])}catch(e){_.oR.error("Failed to fetch categories"),K([])}}},ti=()=>eE||((null==V?void 0:V.tenantType)==="customer"&&(null==V?void 0:V.tenantId)?String(V.tenantId):void 0)||(B?String(B):void 0),to=async()=>{let e=ti();
1if(ee&&e)try{let s=await (0,C.A6)(ee,{requestedTenant:[e]});if(s&&!1!==s.success){var t,a;es(null!=(a=null==s||null==(t=s.data)?void 0:t.results)?a:[])}else _.oR.error((null==s?void 0:s.message)||"Failed to fetch subcategories")}catch(e){_.oR.error("Failed to fetch subcategories")}},td=async()=>{try{let a=await (0,I.Qg)({},{user:V});if(a&&!1!==a.success){var e,t;let s=null!=(t=null==a||null==(e=a.data)?void 0:e.results)?t:[];ed(s)}else _.oR.error((null==a?void 0:a.message)||"Failed to fetch tactics")}catch(e){_.oR.error("Failed to fetch tactics")}},tc=async e=>{if(u&&e)try{let s=await (0,k.Qc)({requestedTenant:e});if(s&&!1!==s.success){var t,a;let e=null!=(a=null==s||null==(t=s.data)?void 0:t.results)?a:[];ef(e)}else _.oR.error((null==s?void 0:s.message)||"Failed to fetch MSSP list")}catch(e){_.oR.error("Failed to fetch groups")}},tu=async()=>{if(L&&U){eW(!0);try{let e=await (0,D.LW)(U,B),t=(null==e?void 0:e.data)||e;if(console.log("Loaded case data:",t),console.log("additionalSummary from API:",null==t?void 0:t.additionalSummary),console.log("additionalSummary type:",typeof(null==t?void 0:t.additionalSummary)),t){if(eM(t),e1(t.title||""),eF(t.tenantId||void 0),e9(t.offenseId||void 0),Z(t.categoryName||void 0),en(t.subCategoryName||void 0),eu(t.tacticName||void 0),t.severity&&(ei(t.severity.toLowerCase()||void 0),console.log("selectedSeverity:",el)),t.analysisSummary)try{let e;"string"==typeof t.analysisSummary?e=JSON.parse(t.analysisSummary):"object"==typeof t.analysisSummary&&(e=t.analysisSummary),e&&(console.log("Setting analysisSummary:",e),eN(e))}catch(e){console.error("Failed to parse analysisSummary:",e)}if(t.remidiations)try{let e;"string"==typeof t.remidiations?e=JSON.parse(t.remidiations):"object"==typeof t.remidiations&&(e=t.remidiations),e&&(console.log("Setting remediations:",e),eA(e))}catch(e){console.error("Failed to parse remidiations:",e)}if(t.additionalSummary){let e=(e=>{let t=(()=>{try{if(!e)return[];let t=e=>{if("string"!=typeof e)return e;let t=e.trim().replace(/,\s*$/,"");if(!t)return t;try{return JSON.parse(t)}catch(e){return t}},a=t(e);for(let e=0;e<3&&"string"==typeof a;e++){let e=t(a);if(e===a)break;a=e}if(a&&"object"==typeof a&&!Array.isArray(a)&&!Array.isArray(a.description)&&1===Object.keys(a).length){let e=Object.keys(a)[0],s=t(e);"string"==typeof s&&(s=t(s)),s&&"object"==typeof s&&(a=s)}let s=e=>{if(Array.isArray(e))return e.length>0&&e[0]&&"object"==typeof e[0]&&Array.isArray(e[0].description)?e[0].description:e.length>0&&e.every(e=>e&&"object"==typeof e&&!Array.isArray(e))?e:[];if(e&&"object"==typeof e){if(Array.isArray(e.description))return e.description;if(Array.isArray(e.additionalSummary)){let t=e.additionalSummary,a=t.find(e=>e&&Array.isArray(e.description));if(Array.isArray(null==a?void 0:a.description))return a.description;if(Array.isArray(t)&&t.every(e=>e&&"object"==typeof e&&!Array.isArray(e)))return t}}return[]},r=s(a);if(r.length>0)return r;let n=e=>{let t=e.indexOf('"description"');if(t<0)return null;let a=e.indexOf("[",t);if(a<0)return null;let s=0,r=!1,n=!1;for(let t=a;t<e.length;t++){let l=e[t];if(n){n=!1;continue}if("\\"===l){n=!0;continue}if('"'===l){r=!r;continue}if(!r&&("["===l&&s++,"]"===l)&&(s--,0===s))return e.slice(a,t+1)}return null};if("string"==typeof e){let a=[];for(let r of(a.push(e),a.push(e.replace(/\\"/g,'"')),a.push(e.replace(/\\"/g,'"').replace(/\\\\/g,"\\")),a)){let e=t(r),a=s(e);if(a.length>0)return a;let l=n(r);if(l)try{let e=JSON.parse(l);if(Array.isArray(e))return e}catch(e){}}}return[]}catch(e){return[]}})();return t.length>0?[{description:t}]:[]})(t.additionalSummary);e.length>0?(console.log("Setting additionalSummary:",e),ts(t=>({...t,additionalSummary:e,description:t.description&&!L?t.description:(e=>{var t;if(!e.length)return"";let a=e.find(e=>{var t;return null==(t=e.description)?void 0:t.length});if(!a||!(null==(t=a.description)?void 0:t.length))return"";let s=a.description,r=Object.keys(s[0]||{}).filter(e=>!!e);return r.length?[r.join(" "),...s.map(e=>r.map(t=>{let a=e[t];return null==a?"":"object"==typeof a?JSON.stringify(a):String(a)}).join(" "))].join("\n"):""})(e)}))):console.log("additionalSummary not set - invalid data:",t.additionalSummary)}if(tn(!1),t.caseGroup&&Array.isArray(t.caseGroup)){let e=t.caseGroup.map(e=>e.groupId);ex(e.length>0?e:void 0)}if(t.caseContributors&&Array.isArray(t.caseContributors)){let e=t.caseContributors.map(e=>e.contributorId);ev(e.length>0?e:void 0)}if(t.caseEvidence&&Array.isArray(t.caseEvidence)){let e=t.caseEvidence.map(e=>({id:e.id,evidenceUrl:e.evidenceUrl}));eG(e),eV(e.map(e=>e.evidenceUrl).filter(e=>!!e))}console.log("Case data loaded successfully"),console.log("Final state.additionalSummary:",ta.additionalSummary)}}catch(e){console.error("Error loading case data:",e),_.oR.error((null==e?void 0:e.message)||"Failed to load case data")}finally{eW(!1)}}},tm=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"save";if(tt)return void _.oR.error(M);let t={tenant:!X&&!(eE||B||((null==V?void 0:V.tenantType)==="customer"&&(null==V?void 0:V.tenantId)?String(V.tenantId):"")),title:!e0.trim(),..."save"===e?{category:!Y,subcategory:!er,severity:!el,tactics:!ec,groups:!eg||0===eg.length,contributors:!ep||0===ep.length}:{}};if(eJ(t),Object.values(t).some(Boolean))return void _.oR.error("Please fill in all required fields");
1if((e_||[]).filter(e=>{let t=(e=>{let t=e.lastIndexOf(".");return t<0?"":e.slice(t+1).toLowerCase()})((null==e?void 0:e.name)||"");return!$.has(t)}).length>0)return void _.oR.error("Please select valid evidence format. Allowed formats: PNG, JPG, JPEG, JFIF.");let a=e8||q||(null==eD?void 0:eD.offenseId)||void 0;eL(!0),eB(e);try{if(L&&U&&!(eT&&"save"===e)){var s;let t=(eg||[]).map(e=>{let t=em.find(t=>t.id===e);return{groupId:e,groupName:(null==t?void 0:t.name)||""}}),r=(ep||[]).filter(e=>"all"!==e).map(e=>{var t,a;let s=ey.find(t=>t.userId===e),r=eH.find(t=>t.id===e),n=(null==r?void 0:r.name)||(s?"".concat(null!=(t=s.firstName)?t:""," ").concat(null!=(a=s.lastName)?a:"").trim():"");return{contributorId:e,contributorName:n||null}}),n=eD||{},l=(ez||[]).map(e=>null==e?void 0:e.evidenceUrl).filter(Boolean),i=eT&&"draft"===e?"Draft":eT&&"save"===e?"Open":void 0,o={...n,title:e0.trim(),analysisSummary:JSON.stringify(ew),categoryName:"draft"===e?Y||null:Y,subCategoryName:"draft"===e?er||null:er,severity:"draft"===e?el||null:el,tacticName:ec||null,caseGroupId:eg||null,caseContributorId:(ep||[]).filter(e=>"all"!==e),caseGroup:t,caseContributors:r,remidiations:JSON.stringify(eS),...tr||(null==(s=ta.additionalSummary)?void 0:s.length)>0?{additionalSummary:ta.additionalSummary}:(null==n?void 0:n.additionalSummary)!==void 0&&(null==n?void 0:n.additionalSummary)!==null&&String(n.additionalSummary).length>0?{additionalSummary:n.additionalSummary}:{},evidence:l,caseEvidence:void 0,offenseId:a||null,...i?{status:i}:{}},d={data:JSON.stringify(o),evidence:e_.length>0?e_:[]};console.log("Update payload evidence:",d.evidence),console.log("Update payload evidence count:",e_.length),console.log("Evidence files:",e_);let c=await (0,D.Zn)(U,d,eE);T(c)?_.oR.error((null==c?void 0:c.message)||(te?M:eT?"draft"===e?"Failed to save draft":"Failed to create case":"Failed to update case")):(_.oR.success((null==c?void 0:c.message)||(eT?"draft"===e?"Draft saved successfully":"Case created successfully":"Case updated successfully")),F(!1),R&&(eC([]),R({mode:e})))}else{let t=(ez||[]).map(e=>null==e?void 0:e.evidenceUrl).filter(Boolean),s={...L&&U&&eT&&"save"===e?{id:U,evidence:t}:{},title:e0.trim(),analysisSummary:JSON.stringify(ew),categoryName:Y||null,subCategoryName:er||null,severity:el||null,tacticName:ec||null,caseGroupId:eg||null,caseContributorId:(ep||[]).filter(e=>"all"!==e),remidiations:JSON.stringify(eS),additionalSummary:ta.additionalSummary,...a?{offenseId:a}:{}},r=eE||B||((null==V?void 0:V.tenantId)?String(V.tenantId):void 0),n={data:JSON.stringify([s]),requestedTenant:r,evidence:e_},l="draft"===e?await (0,D.Rv)(n):await (0,D.uw)(n);T(l)?_.oR.error((null==l?void 0:l.message)||(te?M:"Failed to create case")):(_.oR.success((null==l?void 0:l.message)||("draft"===e?"Draft saved successfully":"Case created successfully")),e1(""),Z(void 0),et(void 0),en(void 0),ei(void 0),eu(void 0),ex(void 0),ev(void 0),eN(E),eA(E),eC([]),eV([]),eQ([]),e9(q),ts({OpenTableSummary:!1,description:"",additionalSummary:[]}),tn(!1),eF(void 0),eK([]),eZ(""),F(!1),R&&R({mode:e}))}}catch(t){_.oR.error((null==t?void 0:t.message)||(te?M:L?"Failed to update case":"draft"===e?"Failed to save draft":"Failed to create case"))}finally{eL(!1),eB(null)}};(0,r.useEffect)(()=>{if(!u){eJ({}),(null==V?void 0:V.tenantType)==="customer"?eF(((null==V?void 0:V.tenantId)?String(V.tenantId):"")||void 0):eF(void 0);return}eC([]),(!L||eT)&&(null==V?void 0:V.tenantType)==="customer"&&eF((null==V?void 0:V.tenantId)?String(V.tenantId):void 0),td(),L&&U?tu():(e1(""),Z(void 0),et(void 0),en(void 0),ei(void 0),eu(void 0),ex(void 0),ev(void 0),eN(E),eA(E),eC([]),eV([]),eQ([]),e9(q),eM(null),ts({OpenTableSummary:!1,description:"",additionalSummary:[]}),tn(!1),eK([]),eZ(""),(null==V?void 0:V.tenantType)==="customer"||(B?eF(B):eF(void 0)))},[u,L,U,q,B,eT]);let tf=(0,r.useRef)(void 0);(0,r.useEffect)(()=>{if(!u){tf.current=void 0;return}let e=ti(),t=tf.current;if(t&&e&&t!==e&&(!L||eT)&&(Z(void 0),et(void 0),en(void 0),es([])),tf.current=e,!e)return void K([]);tl(e)},[u,eE,null==V?void 0:V.tenantType,null==V?void 0:V.tenantId,B,L,eT]),(0,r.useEffect)(()=>
1{if(!u)return;let e=eE||((null==V?void 0:V.tenantType)==="customer"&&(null==V?void 0:V.tenantId)?String(V.tenantId):void 0)||(B?String(B):void 0);e&&tc(String(e))},[u,eE,null==V?void 0:V.tenantType,null==V?void 0:V.tenantId,B]),(0,r.useEffect)(()=>{ee&&u&&ti()&&to()},[ee,u,eE,null==V?void 0:V.tenantId,B]);let tp=(0,r.useMemo)(()=>new Set((eH||[]).map(e=>e.id)),[eH]),tv=(0,r.useMemo)(()=>new Set((ey||[]).map(e=>String(e.userId))),[ey]);return(0,r.useEffect)(()=>{if(eg&&eg.length>0){let e=em.filter(e=>eg.includes(e.id)),t=[],a=new Set;e.forEach(e=>{e.users&&Array.isArray(e.users)&&e.users.forEach(e=>{a.has(e.userId)||(a.add(e.userId),t.push(e))})}),eh(t);let s=(eb||[]).filter(e=>a.has(e));s.length!==(eb||[]).length&&ej(s),ev(e=>{let t=(e||[]).map(String).filter(e=>tp.has(e)),r=new Set(s),n=Array.from(a).filter(e=>!r.has(e)),l=Array.from(new Set([...t,...n]));if(0!==l.length)return 0===r.size&&n.length===a.size?["all",...l]:l})}else eh([]),ej(e=>(null==e?void 0:e.length)?[]:e),ev(e=>{let t=(e||[]).map(String).filter(e=>tp.has(e));return t.length>0?t:void 0})},[eg,em,tp,eb]),(0,r.useEffect)(()=>{if(L&&Y&&H.length>0&&!ee){let e=H.find(e=>e.categoryName===Y);e&&et(e.id)}},[L,Y,H,ee]),(0,s.jsx)(n.a,{heading:L&&!eT?"Edit Case":"Create Case",open:u,onOpenChange:F,showClose:!0,className:"","data-sentry-element":"Modal","data-sentry-component":"CreateCaseModal","data-sentry-source-file":"CreateCaseModal.tsx",children:(0,s.jsxs)("div",{className:"mx-auto max-w-[400px] space-y-4 md:max-w-2xl",children:[eP&&(0,s.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,s.jsx)("div",{className:"text-center",children:(0,s.jsx)("div",{className:"text-muted-foreground mb-2 text-sm",children:"Loading case data..."})})}),!eP&&(0,s.jsxs)(s.Fragment,{children:[(!L||eT)&&(0,s.jsx)(s.Fragment,{children:!X&&(0,s.jsx)(N.F,{id:"case-tenant-select",label:"Tenant",placeholder:"Select a tenant",value:null!=eE?eE:void 0,onValueChange:e=>{eF(e),e&&eJ(e=>({...e,tenant:!1}))},hideForCustomer:!0,fetchParams:{tenantType:"customer"},required:!0,error:eq.tenant?"Tenant is required":void 0})}),(0,s.jsx)(o.D,{id:"case-name",label:"Case Title",required:!0,error:eq.title?"Case Title is required":void 0,type:"text",placeholder:"Enter case title",value:e0,onChange:e=>{e1(e.target.value),e.target.value.trim()&&eJ(e=>({...e,title:!1}))},disabled:eR}),(0,s.jsxs)("div",{className:"relative space-y-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsx)(l.J,{htmlFor:"case-analysis-summary",children:"Analysis Summary"}),e5&&(0,s.jsxs)("span",{className:"text-muted-foreground flex items-center gap-1.5 text-xs",children:[(0,s.jsx)(g.A,{className:"h-3.5 w-3.5 animate-pulse"}),"Dexter is drafting..."]})]}),(0,s.jsx)(p.K,{editorSerializedState:ew,onSerializedChange:e=>eN(e),allowImages:!1,streamedText:e3.summary||void 0})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)(l.J,{htmlFor:"case-additionalSummary",children:"Paste Additional Summary"}),(0,s.jsxs)(c.$,{variant:"actionModal",onClick:()=>{ts(e=>({...e,OpenTableSummary:!0}))},children:[(0,s.jsx)(v.A,{className:"mr-1 h-4 w-4"}),"ADD"]})]}),(null==ta||null==(t=ta.additionalSummary)?void 0:t.length)>0&&(null==ta||null==(a=ta.additionalSummary)?void 0:a.map((e,t)=>(0,s.jsxs)("div",{className:"mt-2 flex flex-col rounded border",children:[(0,s.jsx)("div",{className:"my-4 overflow-y-hidden rounded-lg border border-[var(--primary)]",children:0===e.description.length?(0,s.jsx)("div",{className:"p-4 text-gray-400",children:"No data found"}):(0,s.jsxs)(b.XI,{children:[(0,s.jsx)(b.A0,{children:(0,s.jsx)(b.Hj,{className:"bg-[var(--primary)] hover:bg-[var(--primary)]",children:Object.keys(e.description[0]||{}).map((e,t)=>(0,s.jsx)(b.nd,{className:"sticky top-0 z-10 bg-[var(--primary)] font-semibold text-white",children:e},t))})}),(0,s.jsx)(b.BF,{children:e.description.map((e,t)=>(0,s.jsx)(b.Hj,{children:Object.values(e||{}).map((e,t)=>{let a="object"==typeof e&&null!==e?JSON.stringify(e,null,2):String(null!=e?e:"");return(0,s.jsx)(b.nA,{children:a},t)})},t))})]})}),(0,s.jsx)(c.$,{variant:"outline",size:"sm",className:"self-end border-red-500 text-red-500 hover:bg-red-50",onClick:()=>(e=>{let t=ta.additionalSummary.filter((t,a)=>a!==e);ts(e=>({...e,additionalSummary:t})),tn(!0)})(t),children:"Delete"})]},t))),ta.OpenTableSummary&&(0,s.jsxs)("div",{className:"flex flex-col space-y-4",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("div",{className:"mb-2 text-sm text-[var(--primary)]",children:"Instructions: Copy data from Excel and paste here. Make sure to include headers in the first row."}),(0,s.jsx)(h.T,{onChange:e=>{ts(t=>({...t,description:e.target.value}))},name:"description",placeholder:"Paste Excel table data here... (Copy from Excel and paste here - columns should be tab-separated)",value:ta.description,rows:8,className:"resize-none border-[var(--primary)] bg-slate-700 text-white"})]}),(0,s.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,s.jsx)(c.$,{variant:"default",onClick:()=>
1{if(""!==ta.description){let e=(e=>{if(!e.includes("\n"))return alert("Please add a new line"),null;{e.endsWith("\n")&&(e=e.slice(0,-1));let t=e.split("\n"),a=t[0].split(" "),s=[];return t.forEach((e,t)=>{if(t>0){let t={},r=e.split(" ");a.forEach((e,a)=>{t[e]=r[a]}),s.push(t)}}),s}})(ta.description);if(e){let t=[...ta.additionalSummary,{description:e}];ts(e=>({...e,additionalSummary:t,OpenTableSummary:!1,description:""})),tn(!0)}}},children:"Add Table"}),(0,s.jsx)(c.$,{variant:"outline",className:"border-red-500 text-red-500 hover:bg-red-50",onClick:()=>ts(e=>({...e,OpenTableSummary:!1,description:""})),children:"Cancel"})]})]})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(l.J,{htmlFor:"case-description",children:"Evidence (PNG / JPEG / Excel )"}),L&&ez.length>0&&(0,s.jsxs)("div",{className:"mb-2",children:[(0,s.jsx)("p",{className:"text-muted-foreground mb-2 text-sm",children:"Existing Evidence:"}),(0,s.jsx)("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-3",children:ez.map((e,t)=>(0,s.jsxs)("div",{className:"group relative",children:[(0,s.jsx)("img",{src:O(e.evidenceUrl),alt:"Evidence ".concat(t+1),className:"max-h-28 w-full rounded-lg border object-contain"}),(0,s.jsxs)("div",{className:"absolute top-2 right-2 flex gap-2",children:[(0,s.jsx)(x.A,{onClick:()=>ek(O(e.evidenceUrl)),className:"h-4 w-4 cursor-pointer text-[var(--editIcon)]"}),(0,s.jsx)(y.A,{onClick:()=>{!eR&&(eG(t=>t.filter(t=>t.evidenceUrl!==e.evidenceUrl&&t.id!==e.id)),eV(t=>t.filter(t=>t!==e.evidenceUrl)),eQ(t=>t.includes(e.evidenceUrl)?t:[...t,e.evidenceUrl]),_.oR.success("Evidence marked for removal"))},className:"h-4 w-4 ".concat(eR?"cursor-not-allowed opacity-50":"cursor-pointer"," text-[var(--deleteIcon)]")})]})]},e.id||t))})]}),(0,s.jsx)(n.a,{heading:"Image Preview",open:!!eI,onOpenChange:()=>ek(null),children:eI&&(0,s.jsx)("img",{src:eI,alt:"Preview",className:"h-auto w-full rounded-lg object-contain"})}),L&&(0,s.jsx)("p",{className:"text-muted-foreground mb-2 text-sm",children:"Add New Evidence:"}),(0,s.jsx)(j.A,{onFilesChange:eC},Q)]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-4 space-y-2",children:[(0,s.jsx)(d.P,{id:"category-select",label:"Category",required:!0,error:eq.category?"Category is required":void 0,value:ee,onValueChange:e=>{et(e);let t=H.find(t=>t.id===e);t&&Z(t.categoryName),en(void 0),es([]),e&&eJ(e=>({...e,category:!1,subcategory:!1}))},disabled:!ti()||eR,placeholder:ti()?"Choose a category":"Select tenant first",children:(0,s.jsx)(i.gC,{children:H.map(e=>(0,s.jsx)(i.eb,{chip:e.origin?String(e.origin):void 0,value:e.id,children:e.categoryName},e.id))})}),(0,s.jsx)(d.P,{id:"subcategory-select",label:"Subcategory",required:!0,error:eq.subcategory?"Subcategory is required":void 0,value:er,onValueChange:e=>{en(e),e&&eJ(e=>({...e,subcategory:!1}))},disabled:!ee,placeholder:"Choose a subcategory",children:(0,s.jsx)(i.gC,{children:ea.map(e=>(0,s.jsx)(i.eb,{chip:e.origin?String(e.origin):void 0,value:e.subCategoryName,children:e.subCategoryName},e.id))})}),(0,s.jsx)(d.P,{id:"severity-select",label:"Severity",required:!0,error:eq.severity?"Severity is required":void 0,value:el,onValueChange:e=>{ei(e),e&&eJ(e=>({...e,severity:!1}))},placeholder:"Choose a severity",children:(0,s.jsxs)(i.gC,{children:[(0,s.jsx)(i.eb,{value:"low",children:"Low"}),(0,s.jsx)(i.eb,{value:"medium",children:"Medium"}),(0,s.jsx)(i.eb,{value:"high",children:"High"})]})}),(0,s.jsx)(d.P,{id:"tactics-select",label:"Tactics",required:!0,error:eq.tactics?"Tactics is required":void 0,value:ec,onValueChange:e=>{eu(e),e&&eJ(e=>({...e,tactics:!1}))},placeholder:"Choose a tactic",children:(0,s.jsx)(i.gC,{children:eo.map(e=>(0,s.jsx)(i.eb,{value:e.tacticName,children:e.tacticName},e.id))})}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)(l.J,{htmlFor:"case-groups",children:["Groups",(0,s.jsxs)("span",{className:eq.groups?"text-red-400":"text-white",children:[" ","*"]})]}),(0,s.jsx)(w.K,{options:em.map(e=>({value:e.id,label:e.name})),value:eg||[],onChange:e=>{ex(e),e&&e.length>0&&eJ(e=>({...e,groups:!1}))},placeholder:"Choose groups",className:eq.groups?"border-red-500":""}),eq.groups&&(0,s.jsx)("p",{className:"text-xs text-red-400",children:"At least one group is required"})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)(l.J,{htmlFor:"case-contributors",children:["Contributors",(0,s.jsxs)("span",{className:eq.contributors?"text-red-400":"text-white",children:[" ","*"]})]}),(0,s.jsx)(w.K,{options:[...ey.length>0||eH.length>0?[{label:"All",value:"all"}]:[],...ey.map(e=>{var t;return{value:e.userId,label:"".concat(null!=(t=e.email)?t:"").trim()}}),...eH.map(e=>({value:e.id,label:e.name}))],value:ep||[],onChange:e=>{let t=(e||[]).map(String),a=(ep||[]).map(String),s=a.filter(e=>tv.has(e)&&!t.includes(e)),r=t.filter(e=>tv.has(e)&&!a.includes(e));(s.length>0||r.length>0)&&ej(e=>{let t=new Set((e||[]).map(String));
1return s.forEach(e=>t.add(e)),r.forEach(e=>t.delete(e)),Array.from(t)}),ev(t.length>0?t:void 0),e&&e.length>0&&eJ(e=>({...e,contributors:!1}))},placeholder:"Choose or add contributors",className:eq.contributors?"border-red-500":""}),eq.contributors&&(0,s.jsx)("p",{className:"text-xs text-red-400",children:"At least one contributor is required"})]})]}),(0,s.jsxs)("div",{className:"relative space-y-2",children:[(0,s.jsx)(l.J,{htmlFor:"Remediations",children:"Remediations"}),(0,s.jsx)(p.K,{editorSerializedState:eS,onSerializedChange:e=>eA(e),allowImages:!1,streamedText:e3.remediation||void 0})]}),(0,s.jsxs)("div",{className:"flex justify-end gap-2",children:[(!L||eT)&&(0,s.jsx)(c.$,{type:"button",variant:"outline",onClick:()=>tm("draft"),disabled:eR||eP||tt,children:eR&&"draft"===eU?"Saving Draft...":L?"Save Draft":"Save as Draft"}),(0,s.jsx)(c.$,{type:"button",onClick:()=>tm("save"),disabled:eR||eP||tt,children:eR?"draft"===eU?"Saving Draft...":eT?"Creating...":L?"Updating...":"Creating...":eT?"Create Case":L?"Update Case":"Create Case"})]})]})]})})}},90540:(e,t,a)=>{a.d(t,{Ay:()=>q,xK:()=>R});var s=a(95155),r=a(12115),n=a(45981),l=a(92500),i=a(37911),o=a(70747),d=a(83391),c=a(80415),u=a(31376),m=a(64074),f=a(51588),p=a(72226),v=a(75257),g=a(26420),x=a(42869),y=a(7810),h=a(13963),b=a(72081),j=a(65957),w=a(23609),N=a(11205),S=a(74331),A=a(54335),_=a(87136),C=a(22040),I=a(71580),k=a(22980),D=a(73124),M=a(33936),O=a(60002),T=a(3134),E=a(59118),F=a(82572);let R=e=>{if(!e)return"";try{let t=JSON.parse(e),a=e=>e.text?e.text:e.children?e.children.map(a).join(""):"";return a(t.root)}catch(t){return e}},L=e=>{if(!e)return null;try{let t=JSON.parse(e);if(t&&"object"==typeof t&&t.root)return t;return null}catch(e){return null}},U=e=>{var t;let a=e=>e.some(e=>{var t;return(null==e?void 0:e.type)==="text"?(null==(t=e.text)?void 0:t.trim().length)>0:Array.isArray(null==e?void 0:e.children)?a(e.children):(null==e?void 0:e.type)&&"paragraph"!==e.type&&"linebreak"!==e.type}),s=null==e||null==(t=e.root)?void 0:t.children;return!Array.isArray(s)||!a(s)},B=e=>{if(!e)return"";let t=new Date(e);return isNaN(t.getTime())?e:t.toLocaleString(void 0,{year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit"})};function q(e){var t,a;let{open:R,setOpen:q,caseId:J,tenantId:P,initialData:W,onStatusChange:z,onRefreshList:G,onOpenOffense:$}=e,{t:V}=(0,n.ok)(),{user:X}=(0,k.J)(),Q="https://platform.socbyte.ai/api/casemanagement".replace(/\/+$/,""),[H,K]=(0,r.useState)(!1),[Y,Z]=(0,r.useState)(null),[ee,et]=(0,r.useState)(!1),[ea,es]=(0,r.useState)(!1);(0,r.useEffect)(()=>{(async()=>{if(R&&J){(null==W?void 0:W.id)&&Z(W),K(!0);try{var e;let t=await (0,c.LW)(J,null!=(e=null!=P?P:null==W?void 0:W.tenantId)?e:null);if((null==t?void 0:t.success)&&(null==t?void 0:t.data)){let e=(0,c.aS)(t);e&&Z(e)}else(null==W?void 0:W.id)||(u.toast.error((null==t?void 0:t.message)||"Failed to fetch case details"),q(!1))}catch(e){(null==W?void 0:W.id)||(u.toast.error("Failed to fetch case details"),q(!1))}finally{K(!1)}}})()},[R,J,P,W,q]),(0,r.useEffect)(()=>{R||Z(null)},[R]);let er=async()=>{if(!(null==Y?void 0:Y.id))return;let e=String(Y.status||"").toLowerCase();if("draft"===e||"drafted"===e)return void u.toast.error("Draft cases cannot be closed. Finalize the draft first.");let t=String((null==Y?void 0:Y.tenantId)||P||"");if(!t)return void u.toast.error("Tenant ID is required");try{let a=await (0,c.dg)([String(Y.id)],"closed"===e?"Reopened":"Closed",[t]);if(null==a?void 0:a.success){u.toast.success((null==a?void 0:a.message)||"Case status updated");let e=await (0,c.LW)(String(Y.id),t);if((null==e?void 0:e.success)&&(null==e?void 0:e.data)){let t=(0,c.aS)(e);t&&Z(e=>(0,c.a2)(e,t))}G&&G()}else u.toast.error((null==a?void 0:a.message)||"Failed to update case status")}catch(e){u.toast.error((null==e?void 0:e.message)||"Failed to update case status")}},en=null==Y?void 0:Y.additionalSummary,[el,ei]=(0,r.useState)([]),eo=(0,r.useMemo)(()=>(function(e){try{if(!e)return[];let t=e=>{if("string"!=typeof e)return e;let t=e.trim().replace(/,\s*$/,"");if(!t)return t;try{return JSON.parse(t)}catch(e){return t}},a=t(e);for(let e=0;e<3&&"string"==typeof a;e++){let e=t(a);if(e===a)break;a=e}if(a&&"object"==typeof a&&!Array.isArray(a)&&!Array.isArray(a.description)&&1===Object.keys(a).length){let e=Object.keys(a)[0],s=t(e);"string"==typeof s&&(s=t(s)),s&&"object"==typeof s&&(a=s)}let s=e=>{if(Array.isArray(e))return e.length>0&&e[0]&&"object"==typeof e[0]&&Array.isArray(e[0].description)?e[0].description:(e.length>0&&e.every(e=>e&&"object"==typeof e&&!Array.isArray(e)),e);if(e&&"object"==typeof e){if(Array.isArray(e.description))return e.description;if(Array.isArray(e.additionalSummary)){let t=e.additionalSummary,a=t.find(e=>e&&Array.isArray(e.description));return Array.isArray(null==a?void 0:a.description)?a.description:t}}return[]},r=s(a);if(r.length>0)return r;let n=e=>{let t=e.indexOf('"description"');
1if(t<0)return null;let a=e.indexOf("[",t);if(a<0)return null;let s=0,r=!1,n=!1;for(let t=a;t<e.length;t++){let l=e[t];if(n){n=!1;continue}if("\\"===l){n=!0;continue}if('"'===l){r=!r;continue}if(!r&&("["===l&&s++,"]"===l)&&(s--,0===s))return e.slice(a,t+1)}return null};if("string"==typeof e){let a=[];for(let r of(a.push(e),a.push(e.replace(/\\"/g,'"')),a.push(e.replace(/\\"/g,'"').replace(/\\\\/g,"\\")),a)){let e=t(r),a=s(e);if(a.length>0)return a;let l=n(r);if(l)try{let e=JSON.parse(l);if(Array.isArray(e))return e}catch(e){}}}return[]}catch(e){return console.error("â Failed to parse additionalSummary:",e),[]}})(en),[en]),ed=(0,r.useMemo)(()=>{let e=new Set;return eo.forEach(t=>Object.keys(t||{}).forEach(t=>e.add(t))),Array.from(e)},[eo]),ec=(0,r.useMemo)(()=>ed.map(e=>({id:e,accessorFn:t=>t[e],header:t=>{let{column:a}=t;return(0,s.jsx)(M.w,{column:a,title:e})},cell:t=>{let{row:a}=t,r=a.original[e],n="object"==typeof r&&null!==r?JSON.stringify(r,null,2):String(null!=r?r:"");return(0,s.jsx)("span",{className:"text-sm break-words whitespace-pre-wrap text-gray-200",children:n})}})),[ed]),eu=(0,O.N4)({data:eo,columns:ec,state:{sorting:el},onSortingChange:ei,getCoreRowModel:(0,T.HT)(),getSortedRowModel:(0,T.h5)()}),em=(0,r.useMemo)(()=>((null==Y?void 0:Y.comments)||[]).map(e=>(0,c.jY)(e)),[null==Y?void 0:Y.comments]);if(!R)return null;if(H)return(0,s.jsx)(i.a,{heading:"Loading Case Details...",open:R,onOpenChange:q,showClose:!0,className:"w-full lg:max-w-5xl",children:(0,s.jsxs)("div",{className:"space-y-4 p-4",children:[(0,s.jsx)(m.E,{className:"h-8 w-3/4"}),(0,s.jsx)(m.E,{className:"h-4 w-1/2"}),(0,s.jsx)("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-3",children:Array.from({length:8}).map((e,t)=>(0,s.jsx)(m.E,{className:"h-6 w-full"},t))}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,s.jsx)(m.E,{className:"h-32 w-full"}),(0,s.jsx)(m.E,{className:"h-32 w-full"})]})]})});if(!Y)return(0,s.jsx)(i.a,{heading:"Case Details",open:R,onOpenChange:q,showClose:!0,className:"w-full lg:max-w-5xl",children:(0,s.jsx)("div",{className:"p-4 text-center",children:(0,s.jsx)("p",{className:"text-muted-foreground",children:"No case data available"})})});let ef=(Y.caseContributors||[]).map((e,t)=>({id:String(t),caseContributorId:e.contributorId,name:e.contributorName||"Unknown User",email:""})),ep=(Y.caseGroup||[]).map((e,t)=>({id:String(t),caseGroupId:e.groupId,name:e.groupName})),ev=(Y.caseEvidence||[]).map(e=>e.evidenceUrl),eg=Array.isArray(Y.linkedOffenses)?Y.linkedOffenses.filter(e=>!!(null==e?void 0:e.id)):Y.offenseId?[{id:String(Y.offenseId)}]:[],ex=L(Y.analysisSummary),ey=L(Y.remidiations);return(0,s.jsxs)(i.a,{heading:"Case Reference ID: ".concat(Y.referenceId||Y.id),open:R,onOpenChange:q,showClose:!0,className:"lg:min-w-[65vw]","data-sentry-element":"Modal","data-sentry-component":"CaseDetailsModal","data-sentry-source-file":"CaseDetailModal.tsx",children:[(0,s.jsxs)("div",{className:"mx-4 my-4 space-y-4",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsx)("div",{className:"min-w-0 flex-1",children:(0,s.jsx)("h2",{className:"text-lg font-semibold text-white",children:Y.title})}),(0,s.jsx)("div",{className:"shrink-0",children:(0,s.jsxs)(f.rI,{"data-sentry-element":"DropdownMenu","data-sentry-source-file":"CaseDetailModal.tsx",children:[(0,s.jsx)(f.ty,{asChild:!0,"data-sentry-element":"DropdownMenuTrigger","data-sentry-source-file":"CaseDetailModal.tsx",children:(0,s.jsxs)(o.$,{variant:"ghost",size:"icon",className:"bg-muted hover:bg-muted/80 h-6 w-6 p-1 transition-colors","data-sentry-element":"Button","data-sentry-source-file":"CaseDetailModal.tsx",children:[(0,s.jsx)("span",{className:"sr-only",children:"Open actions"}),(0,s.jsx)(h.A,{className:"h-4 w-4","data-sentry-element":"IconDotsVertical","data-sentry-source-file":"CaseDetailModal.tsx"})]})}),(0,s.jsxs)(f.SQ,{align:"end",className:"min-w-[160px]","data-sentry-element":"DropdownMenuContent","data-sentry-source-file":"CaseDetailModal.tsx",children:[(0,s.jsx)(f.lp,{"data-sentry-element":"DropdownMenuLabel","data-sentry-source-file":"CaseDetailModal.tsx",children:"Actions"}),(0,s.jsx)(f.mB,{"data-sentry-element":"DropdownMenuSeparator","data-sentry-source-file":"CaseDetailModal.tsx"}),(0,s.jsxs)(f._2,{onClick:()=>{et(!0)},"data-sentry-element":"DropdownMenuItem","data-sentry-source-file":"CaseDetailModal.tsx",children:[(0,s.jsx)(b.A,{className:"h-4 w-4 text-[var(--primary)]","data-sentry-element":"IconDownload","data-sentry-source-file":"CaseDetailModal.tsx"})," ","Download"]}),(null==(t=Y.status)?void 0:t.toLowerCase())!=="closed"&&(0,s.jsxs)(f._2,{onClick:()=>{es(!0)},children:[(0,s.jsx)(j.A,{className:"h-4 w-4 text-[var(--editIcon)]"})," Edit"]}),!["draft","drafted"].includes(String(Y.status||"").toLowerCase())&&(0,s.jsx)(f._2,{onClick:er,children:(null==(a=Y.status)?void 0:a.toLowerCase())==="closed"?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(w.A,{className:"h-4 w-4 text-[var(--open-text)]"})," ","Reopen"]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(N.A,{className:"h-4 w-4 text-[var(--close-text)]"})," ","Close"]})})]})]})})]}),(0,s.jsxs)("div",{className:"bg-card grid grid-cols-2 gap-4 roun
1ded-lg p-4 text-sm md:grid-cols-3",children:[(0,s.jsx)(E.W7,{label:"Category",value:Y.categoryName||"-","data-sentry-element":"InfoItem","data-sentry-source-file":"CaseDetailModal.tsx"}),(0,s.jsx)(E.W7,{label:"Created At",value:B(Y.createdAt),"data-sentry-element":"InfoItem","data-sentry-source-file":"CaseDetailModal.tsx"}),(0,s.jsx)(E.W7,{label:"Severity",value:Y.severity,"data-sentry-element":"InfoItem","data-sentry-source-file":"CaseDetailModal.tsx"}),(0,s.jsx)(E.W7,{label:"Tactic",value:Y.tacticName||"-","data-sentry-element":"InfoItem","data-sentry-source-file":"CaseDetailModal.tsx"}),(0,s.jsx)(E.W7,{label:"Status",value:(0,s.jsx)(g.E,{...(e=>{switch(null==e?void 0:e.toLowerCase()){case"open":return{className:"bg-[var(--open)]/20 text-[var(--open-text)]"};case"closed":return{className:"bg-[var(--close)]/20 text-[var(--close-text)]"};case"in-progress":case"pending":return{className:"bg-[var(--inprogress)]/20 text-[var(--inprogress-text)]"};default:return{variant:"default",className:"bg-gray-600 text-white hover:bg-gray-700"}}})(Y.status),children:(e=>{let t=String(e||"").trim();if(!t)return"-";let a=t.toLowerCase();return"closed"===a?"Closed":"reopened"===a?"Reopened":"inprogress"===a?"In Progress":a.replace(/[_-]+/g," ").split(" ").filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")})(Y.status)}),"data-sentry-element":"InfoItem","data-sentry-source-file":"CaseDetailModal.tsx"}),(0,s.jsx)(E.W7,{label:"Tenant",value:Y.tenantName||"-","data-sentry-element":"InfoItem","data-sentry-source-file":"CaseDetailModal.tsx"}),(0,s.jsx)(E.W7,{label:"Created By",value:Y.createdByUserName||"-","data-sentry-element":"InfoItem","data-sentry-source-file":"CaseDetailModal.tsx"}),(0,s.jsx)(E.W7,{label:"Closed At",value:B(Y.closed_at||Y.closedAt)||"-","data-sentry-element":"InfoItem","data-sentry-source-file":"CaseDetailModal.tsx"}),(0,s.jsx)(E.W7,{label:"Sub Category",value:Y.subCategoryName||"-","data-sentry-element":"InfoItem","data-sentry-source-file":"CaseDetailModal.tsx"}),(0,s.jsx)(E.W7,{label:"Closed By",value:Y.closedByName||"-","data-sentry-element":"InfoItem","data-sentry-source-file":"CaseDetailModal.tsx"})]})]}),(0,s.jsxs)("div",{className:"mx-4 mb-4 grid grid-cols-1 items-stretch gap-4 lg:grid-cols-2",children:[(0,s.jsxs)(v.Zp,{className:"flex h-full min-h-40 flex-col p-2","data-sentry-element":"Card","data-sentry-source-file":"CaseDetailModal.tsx",children:[(0,s.jsxs)("h3",{className:"mb-2 flex shrink-0 items-center font-semibold text-white",children:[(0,s.jsx)(x.A,{className:"mr-2 h-4 w-4 text-[var(--primary)]","data-sentry-element":"User","data-sentry-source-file":"CaseDetailModal.tsx"})," ",V("Contributors")]}),(0,s.jsx)(p.F,{className:"min-h-24 flex-1","data-sentry-element":"ScrollArea","data-sentry-source-file":"CaseDetailModal.tsx",children:ef.length>0?(0,s.jsx)("ul",{className:"grid grid-cols-1 gap-2",children:ef.map(e=>(0,s.jsxs)("li",{className:"flex items-center gap-2 border-l-2 border-[var(--primary)] pl-2",children:[(0,s.jsx)(x.A,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),(0,s.jsx)("p",{className:"text-sm text-white",children:e.name})]},e.id))}):(0,s.jsx)(F.I,{title:"No contributors assigned"})})]}),(0,s.jsxs)(v.Zp,{className:"flex h-full min-h-40 flex-col p-2","data-sentry-element":"Card","data-sentry-source-file":"CaseDetailModal.tsx",children:[(0,s.jsxs)("h3",{className:"mb-2 flex shrink-0 items-center font-semibold text-white",children:[(0,s.jsx)(y.A,{className:"mr-2 h-4 w-4 text-[var(--primary)]","data-sentry-element":"Users","data-sentry-source-file":"CaseDetailModal.tsx"})," ",V("Groups")]}),(0,s.jsx)(p.F,{className:"min-h-24 flex-1","data-sentry-element":"ScrollArea","data-sentry-source-file":"CaseDetailModal.tsx",children:ep.length>0?(0,s.jsx)("ul",{className:"grid grid-cols-1 space-y-2 md:grid-cols-2",children:ep.map(e=>(0,s.jsxs)("li",{className:"flex items-center gap-2 border-l-2 border-[var(--primary)] pl-2",children:[(0,s.jsx)(y.A,{className:"h-4 w-4 text-[var(--primary)]"}),(0,s.jsx)("p",{className:"text-sm text-white",children:e.name})]},e.id))}):(0,s.jsx)(F.I,{title:"No groups assigned"})})]})]}),(0,s.jsxs)("div",{className:"mx-4 mb-4",children:[(0,s.jsxs)(S.tU,{defaultValue:"analysis","data-sentry-element":"Tabs","data-sentry-source-file":"CaseDetailModal.tsx",children:[(0,s.jsxs)(S.j7,{"data-sentry-element":"TabsList","data-sentry-source-file":"CaseDetailModal.tsx",children:[(0,s.jsx)(S.Xi,{value:"analysis","data-sentry-element":"TabsTrigger","data-sentry-source-file":"CaseDetailModal.tsx",children:"Analysis Summary"}),(0,s.jsx)(S.Xi,{value:"evidence","data-sentry-element":"TabsTrigger","data-sentry-source-file":"CaseDetailModal.tsx",children:"Evidence"}),(0,s.jsx)(S.Xi,{value:"remediation","data-sentry-element":"TabsTrigger","data-sentry-source-file":"CaseDetailModal.tsx",children:"Remediation"}),!["draft","drafted"].includes(String((null==Y?void 0:Y.status)||"").toLowerCase())&&(0,s.jsx)(S.Xi,{value:"comments",children:"Comments"}),(null==Y?void 0:Y.additionalSummary)&&(0,s.jsx)(S.Xi,{value:"additionalSummary",children:"Additional Summary"}),eg.length>0&&(0,s.jsxs)(S.Xi,{value:"linkedOffenses",children:["Linked Offenses (",eg.length,")"]})]}),(0,s.jsx)(S.av,{value:"analysis",className:"bg-card rounded-lg px-4 py-2","data-sentry-element":"TabsContent","data-sentry-source-file":"CaseDetailModal.tsx",children:(0,s.jsx)("div",{children:ex&&!U(ex)?(0,s.jsx)("div",{className:"mt-2 text-sm text-white",children:(0,s.jsx)(I.I,{editorSerializedState:ex})}):(0,s.jsx)(F.I,{})})}),(0,s.jsx)(S.av,{value:"additionalSummary",className:"bg-card rounded-lg px-4 py-2","data-sentry-element":"TabsContent","data-sentry-source-file":"CaseDetailModal.tsx",children:(0,s.jsx)("div",{className:"overflow-x-auto",children:eo.length>0?(0,s.jsx)(D.b,{table:eu,textAlign:"left",showSerial:!0,showPagination:!1,resizableColumns:!0}):(0,s.jsx)(F.I,{})})}),(0,s.jsx)(S.av,{value:"evidence",className:"bg-card rounded-lg px-4 py-2","data-sentry-element":"TabsContent","data-sentry-source-file":"CaseDetailModal.tsx",children:ev.length>0?ev.map((e,t)=>(0,s.jsx)(d.default,{src:(0,C.X3)(e),alt:"Evidence ".concat(t+1),width:2e3,height:2e3,className:"my-2 w-full rounded-lg",unoptimized:!0},t)):(0,s.jsx)(F.I,{})}),(0,s.jsx)(S.av,{value:"remediation",className:"bg-card rounded-lg px-4 py-2","data-sentry-element":"TabsContent","data-sentry-source-file":"CaseDetailModal.tsx",children:(0,s.jsx)("div",{children:ey&&!U(ey)?(0,s.jsx)("div",{className:"mt-2 text-sm text-white",children:(0,s.jsx)(I.I,{editorSerializedState:ey})}):(0,s.jsx)(F.I,{})})}),!["draft","drafted"].includes(String((null==Y?void 0:Y.status)||"").toLowerCase())&&(0,s.jsx)(S.av,{value:"comments",className:"bg-card rounded-lg px-4 py-2",children:(0,s.jsx)(l.A,{comments:em,currentUserId:null==X?void 0:X.userId,maxImages:
15,mediaApiBase:Q,onPost:async(e,t,a)=>{if(!J)return{success:!1,message:"Case ID is required"};let s=await (0,c.zp)(J,e,a,t),r=(0,c.cf)(s);return(null==s?void 0:s.success)&&r&&Z(e=>(0,c.Bm)(e,r)),{success:!!(null==s?void 0:s.success),message:null==s?void 0:s.message}},onUpdate:async(e,t,a,s)=>{let r=await (0,c.Qx)(e,t,a,s),n=(0,c.cf)(r);return(null==r?void 0:r.success)&&n&&Z(e=>(0,c.Bm)(e,n)),{success:!!(null==r?void 0:r.success),message:null==r?void 0:r.message}},onRefresh:async()=>{var e;let t=await (0,c.LW)(J,null!=(e=null!=P?P:null==Y?void 0:Y.tenantId)?e:null),a=(0,c.aS)(t);a&&Z(e=>(0,c.a2)(e,a)),G&&G()}},"case-comments-".concat(J,"-").concat(em.map(e=>{var t;return"".concat(e.id,":").concat((null==(t=e.images)?void 0:t.length)||0)}).join("|")))}),eg.length>0&&(0,s.jsx)(S.av,{value:"linkedOffenses",className:"bg-card rounded-lg px-4 py-2",children:(0,s.jsx)("ul",{className:"grid grid-cols-1 gap-2 py-2",children:eg.map(e=>(0,s.jsxs)("li",{className:"flex min-w-0 flex-wrap items-center gap-2 border-l-2 border-[var(--primary)] pl-2",children:[(0,s.jsx)("button",{type:"button",className:"min-w-0 cursor-pointer border-0 bg-transparent p-0 text-left text-sm leading-snug font-normal break-all text-[var(--primary)] hover:underline",onClick:()=>{var t,a,s;return null==$?void 0:$(String(e.id),null!=(s=null!=(a=null!=(t=e.tenant)?t:P)?a:Y.tenantId)?s:null)},children:e.alertId||e.id}),e.description&&(0,s.jsx)("span",{className:"text-muted-foreground min-w-0 truncate text-xs",children:e.description})]},e.id))})})]}),(0,s.jsx)(A._,{isOpen:ee,onClose:()=>et(!1),record:{id:Y.referenceId||Y.id,title:Y.title,subject:Y.description||"",status:Y.status,severity:Y.severity,tactics:Y.tacticName||"",createdBy:Y.createdByUserName||"",createdDate:B(Y.createdAt),category:Y.categoryName||"",subCategory:Y.subCategoryName||"",tenantName:Y.tenantName||"",age:Y.age||"",offenseId:Y.offenseId||"",caseContributors:ef,caseGroup:ep,analysisSummary:Y.analysisSummary||"",evidence:(ev||[]).map(e=>(0,C.RN)(e)),remediation:Y.remidiations||"",comments:(Y.comments||[]).map(e=>{var t;let a=(Array.isArray(e.images)?e.images:[]).map(e=>{let t=(null==e?void 0:e.commentedImageUrl)||(null==e?void 0:e.commented_image_url)||"",a=(0,C.SZ)(t);return{...e,commentedImageUrl:a,commented_image_url:a}}),s=(null==e?void 0:e.commentedImageUrl)||(null==e?void 0:e.commented_image_url)||(null==(t=a[0])?void 0:t.commented_image_url)||"",r=(0,C.SZ)(s),n=(0,C.$W)((null==e?void 0:e.avatarURL)||(null==e?void 0:e.avatarUrl)||(null==e?void 0:e.avatar_url)||(null==e?void 0:e.imageUrl)||"");return{...e,images:a,avatarURL:n,avatarUrl:n,avatar_url:n,commentedImageUrl:r,commented_image_url:r}})},"data-sentry-element":"CasePdfModal","data-sentry-source-file":"CaseDetailModal.tsx"}),(0,s.jsx)(_.Ay,{open:ea,setOpen:es,editMode:!0,caseId:Y.id,tenantId:null!=P?P:Y.tenantId,caseStatus:Y.status,onSuccess:async()=>{es(!1),q(!1),null==G||G()},"data-sentry-element":"CreateCaseModal","data-sentry-source-file":"CaseDetailModal.tsx"})]})]})}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.