PageSourceSearch

https://delivr.to/assets/Payloads-BhszjqDz.js

js delivr.to collected 2026-10-03 22:10:57 UTC 74,451 bytes, 187 lines download raw bytes

1import{u as J,j as e,a as ft}from"./query-DmstuUoN.js";import{a as l,d as ge,i as Bt}from"./vendor-CHI41uxr.js";import{c as et,U as je,P as Re,F as he,X as te,y as se,b as X,E as ae,T as xt,m as gt,n as jt,o as yt,J as st,s as we,t as Ht,v as Kt,B as G,w as Vt,x as at,q as Gt,r as Wt,u as vt,z as Qt,A as Yt,I as rt,Z as Zt,l as Xt,H as V,K as Jt,L as wt,M as es,S as ts,D as Qe,d as Ye,e as bt,f as Nt,N as ss,k as as,O as rs}from"./index-BNXzEUcY.js";import{I as de}from"./input-CnDjsPPe.js";import{C as qe,S as ns,a as is,b as ls,c as os,d as $e}from"./select-5kNhwI7E.js";import{C as Ct,a as St,b as Tt}from"./collapsible-C7cRw4tP.js";import{p as Q,P as cs,D as ds,M as Ze,a as Xe,b as us,F as ms,C as hs,H as ps,S as fs,Q as xs,g as gs}from"./QuickSendModal-CQmjuf-l.js";import{u as js,T as ys}from"./TemplateFormModal-B37uNYX4.js";import{u as vs}from"./useDocumentTitle-BOGfSQQj.js";import{T as kt,a as Pt,b as pe,c as fe,L as ee}from"./tabs-C7WAY928.js";import{B as H}from"./badge-XJ-ekfky.js";import{I as Fe,F as tt}from"./FileTypeIcon-CIJ8pSho.js";import{M as Ae}from"./mail-Dk4-qTC8.js";import{I as ze}from"./info-Ce8kNf0i.js";import{T as ws,a as bs,b as Ue,c as me,d as Ns,e as ce,C as Cs}from"./table-CUu4M3zy.js";import{A as Ss,a as Ts,b as ks,c as Ps,d as Ms,e as Ds,f as Es,g as Os}from"./alert-dialog-DR35OEje.js";import{L as Mt}from"./switch-CytVYzhY.js";import{G as Ls,D as qs}from"./AreaChart-Ccxmcukk.js";import{M as Fs}from"./more-horizontal-BReLZdfI.js";import{S as Ee}from"./separator-DUsDTrP6.js";import{E as nt}from"./external-link-C0FWOmYM.js";import{C as _s}from"./clock-DzhGAESw.js";import{L as Je}from"./loader-2-RpObhsNd.js";import{T as Dt}from"./textarea-D_Kdk8pI.js";import{C as Be}from"./checkbox-CLrZ-oDk.js";import{U as He}from"./upload-CklfRmdE.js";import{P as Rs}from"./plus-C8Medqfj.js";import"./ui-WgsiDFN4.js";import"./trending-up-DtVV2BY5.js";import"./alert-circle-mXEU0qr-.js";import"./usePayloads-Dd1yRoQC.js";import"./search-CIwB5ZE9.js";const it=et("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);const Et=et("FileType",[["path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z",key:"1nnpy2"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}],["path",{d:"M9 13v-1h6v1",key:"1bb014"}],["path",{d:"M11 18h2",key:"12mj7e"}],["path",{d:"M12 12v6",key:"3ahymv"}]]);const As=et("Save",[["path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z",key:"1owoqh"}],["polyline",{points:"17 21 17 13 7 13 7 21",key:"1md35c"}],["polyline",{points:"7 3 7 8 15 8",key:"8nz8an"}]]);function Ot(t){if(!t)return"";let s=t.replace(/\[([^\]]+)\]\([^)]+\)/g,"$1");return s=s.replace(/\s*\(Citation:[^)]+\)\s*/gi," "),s=s.replace(/\*+([^*]+)\*+/g,"$1"),s=s.replace(/\s+/g," ").trim(),((s.split(/\.\s|\n/)[0]||"").trim()+".").replace(/\.+$/,".")}function zs({selectedTechniques:t,selectedGroups:s,selectedSoftware:a,selectedFileTypes:r,techniques:n,groups:h,softwareList:o,onTechniqueRemove:x,onGroupRemove:m,onSoftwareRemove:S,onFileTypeRemove:D}){return t.length>0||s.length>0||a.length>0||r.length>0?e.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[t.map(y=>{const P=n.find(M=>M.id===y);return e.jsxs(H,{variant:"secondary",className:"gap-1 pr-1",children:[e.jsx(Ae,{className:"h-3 w-3"}),P?.name||y,e.jsx("button",{onClick:()=>x(y),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:e.jsx(te,{className:"h-3 w-3"})})]},`technique-${y}`)}),s.map(y=>{const P=h.find(M=>M.id===y);return e.jsxs(H,{variant:"secondary",className:"gap-1 pr-1",children:[e.jsx(je,{className:"h-3 w-3"}),P?.name||y,e.jsx("button",{onClick:()=>m(y),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:e.jsx(te,{className:"h-3 w-3"})})]},`group-${y}`)}),a.map(y=>{const P=o.find(M=>M.id===y);return e.jsxs(H,{variant:"secondary",className:"gap-1 pr-1",children:[e.jsx(Re,{className:"h-3 w-3"}),P?.name||y,e.jsx("button",{onClick:()=>S(y),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:e.jsx(te,{className:"h-3 w-3"})})]},`software-${y}`)}),r.map(y=>e.jsxs(H,{variant:"secondary",className:"gap-1 pr-1",children:[e.jsx(Et,{className:"h-3 w-3"}),y,e.jsx("button",{onClick:()=>
1D(y),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:e.jsx(te,{className:"h-3 w-3"})})]},`filetype-${y}`))]}):null}function Is({technique:t,count:s,isSelected:a,isDisabled:r,onToggle:n,onInfoClick:h}){return e.jsx(se,{className:X("cursor-pointer transition-all hover:shadow-md h-[158px] min-w-[312px]",a&&"ring-2 ring-primary",r&&"opacity-50 cursor-not-allowed"),onClick:()=>!r&&n(),children:e.jsxs(ae,{className:"p-4 h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx(Ae,{className:"h-5 w-5 text-primary flex-shrink-0"}),e.jsx("span",{className:"font-semibold text-sm truncate",children:t.name})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0 ml-2",children:[e.jsx(H,{variant:"secondary",children:s}),e.jsx("button",{onClick:o=>{o.stopPropagation(),h()},className:"text-muted-foreground hover:text-foreground",children:e.jsx(ze,{className:"h-4 w-4"})})]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground line-clamp-4",children:[t.description?.split(`.
2`)[0]||"","."]})]})})}function $s({group:t,count:s,isSelected:a,isDisabled:r,onToggle:n,onInfoClick:h}){const o=Ot(t.description);return e.jsx(se,{className:X("cursor-pointer transition-all hover:shadow-md h-[158px] min-w-[312px]",a&&"ring-2 ring-primary",r&&"opacity-50 cursor-not-allowed"),onClick:()=>!r&&n(),children:e.jsxs(ae,{className:"p-4 h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx(je,{className:"h-5 w-5 text-primary flex-shrink-0"}),e.jsx("span",{className:"font-semibold text-sm truncate",children:t.name})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0 ml-2",children:[e.jsx(H,{variant:"secondary",children:s}),e.jsx("button",{onClick:x=>{x.stopPropagation(),h()},className:"text-muted-foreground hover:text-foreground",children:e.jsx(ze,{className:"h-4 w-4"})})]})]}),o&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-4",children:o})]})})}function Us({software:t,count:s,isSelected:a,isDisabled:r,onToggle:n,onInfoClick:h}){const o=Ot(t.description);return e.jsx(se,{className:X("cursor-pointer transition-all hover:shadow-md h-[158px] min-w-[312px]",a&&"ring-2 ring-primary",r&&"opacity-50 cursor-not-allowed"),onClick:()=>!r&&n(),children:e.jsxs(ae,{className:"p-4 h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-start justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx(Re,{className:"h-5 w-5 text-primary flex-shrink-0"}),e.jsx("span",{className:"font-semibold text-sm truncate",children:t.name})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0 ml-2",children:[e.jsx(H,{variant:"secondary",children:s}),e.jsx("button",{onClick:x=>{x.stopPropagation(),h()},className:"text-muted-foreground hover:text-foreground",children:e.jsx(ze,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"mb-1",children:e.jsx(H,{variant:t.type==="malware"?"destructive":"outline",className:"text-xs",children:t.type})}),o&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-3",children:o})]})})}function Bs({extension:t,count:s,isSelected:a,isDisabled:r,onToggle:n}){return e.jsx(se,{className:X("cursor-pointer transition-all hover:shadow-md",a&&"ring-2 ring-primary",r&&"opacity-50 cursor-not-allowed"),onClick:()=>!r&&n(),children:e.jsx(ae,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(tt,{extension:t,size:"md"}),e.jsx("span",{className:"font-semibold text-sm",children:t})]}),e.jsx(H,{variant:"secondary",children:s})]})})})}function Hs(t,s,a,r,n){const h=t.filter(x=>{if(s.length>0&&!s.every(m=>x.techniques?.includes(m))||a.length>0&&!a.every(m=>x.groups?.includes(m))||r.length>0&&!r.every(m=>x.software?.includes(m)))return!1;if(n.length>0){const m=new Set([x.extension,...x.file_types||[]]);if(!n.every(S=>m.has(S)))return!1}return!0}),o={techniques:{},groups:{},software:{},file_types:{}};
2for(const x of h){if(x.techniques)for(const m of x.techniques)o.techniques[m]=(o.techniques[m]||0)+1;if(x.groups)for(const m of x.groups)o.groups[m]=(o.groups[m]||0)+1;if(x.software)for(const m of x.software)o.software[m]=(o.software[m]||0)+1;if(o.file_types[x.extension]=(o.file_types[x.extension]||0)+1,x.file_types)for(const m of x.file_types)m!==x.extension&&(o.file_types[m]=(o.file_types[m]||0)+1)}return o}function Ks({activeTab:t,onTabChange:s,selectedTechniques:a,onTechniqueToggle:r,selectedGroups:n,onGroupToggle:h,selectedSoftware:o,onSoftwareToggle:x,selectedFileTypes:m,onFileTypeToggle:S,payloads:D,isLoading:_=!1,metadataCounts:y}){const[P,M]=l.useState(!1),[A,W]=l.useState("technique"),[$,C]=l.useState(null),{data:U=[],isLoading:K}=J({queryKey:["intel","techniques"],queryFn:Q.getTechniques}),{data:F=[],isLoading:i}=J({queryKey:["intel","groups"],queryFn:Q.getGroups}),{data:k=[],isLoading:z}=J({queryKey:["intel","software"],queryFn:Q.getSoftware}),v=l.useMemo(()=>a.length>0||n.length>0||o.length>0||m.length>0?Hs(D,a,n,o,m):y,[D,a,n,o,m,y]),c=l.useMemo(()=>Object.keys(y.file_types).sort(),[y.file_types]),E=u=>{W("technique"),C(u),M(!0)},p=u=>{W("group"),C(u),M(!0)},j=u=>{W("software"),C(u),M(!0)},N=U.filter(u=>(y.techniques[u.id]??0)>0),w=F.filter(u=>(y.groups[u.id]??0)>0),R=k.filter(u=>(y.software[u.id]??0)>0),d=N.filter(u=>{const q=v.techniques[u.id]??0,I=a.includes(u.id);return q>0||I}).length,b=w.filter(u=>{const q=v.groups[u.id]??0,I=n.includes(u.id);return q>0||I}).length,L=R.filter(u=>{const q=v.software[u.id]??0,I=o.includes(u.id);return q>0||I}).length,re=c.filter(u=>{const q=v.file_types[u]??0,I=m.includes(u);return q>0||I}).length;return e.jsxs(e.Fragment,{children:[e.jsxs(kt,{value:t,onValueChange:s,children:[e.jsxs(Pt,{className:"grid w-full grid-cols-4 max-w-xl",children:[e.jsxs(pe,{value:"techniques",className:"gap-2",children:[e.jsx(Ae,{className:"h-4 w-4"}),"Techniques"," ",d>0&&`(${d})`]}),e.jsxs(pe,{value:"groups",className:"gap-2",children:[e.jsx(je,{className:"h-4 w-4"}),"Groups ",b>0&&`(${b})`]}),e.jsxs(pe,{value:"software",className:"gap-2",children:[e.jsx(Re,{className:"h-4 w-4"}),"Software"," ",L>0&&`(${L})`]}),e.jsxs(pe,{value:"filetypes",className:"gap-2",children:[e.jsx(Et,{className:"h-4 w-4"}),"File Types"," ",re>0&&`(${re})`]})]}),e.jsx(fe,{value:"techniques",className:"mt-4",children:K||_?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(he,{})}):N.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No attack techniques available"}):e.jsx("div",{className:"max-h-[460px] overflow-y-auto pr-2",children:e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(312px,1fr))] gap-4 p-1",children:N.map(u=>{const q=v.techniques[u.id]??0,I=a.includes(u.id),Y=q===0&&!I;return e.jsx(Is,{technique:u,count:q,isSelected:I,isDisabled:Y,onToggle:()=>r(u.id),onInfoClick:()=>E(u)},u.id)})})})}),e.jsx(fe,{value:"groups",className:"mt-4",children:i||_?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(he,{})}):w.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No threat groups available"}):e.jsx("div",{className:"max-h-[460px] overflow-y-auto pr-2",children:e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(312px,1fr))] gap-4 p-1",children:w.map(u=>{const q=v.groups[u.id]??0,I=n.includes(u.id),Y=q===0&&!I;return e.jsx($s,{group:u,count:q,isSelected:I,isDisabled:Y,onToggle:()=>h(u.id),onInfoClick:()=>p(u)},u.id)})})})}),e.jsx(fe,{value:"software",className:"mt-4",children:z||_?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(he,{})}):R.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No software available"}):e.jsx("div",{className:"max-h-[460px] overflow-y-auto pr-2",children:e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(312px,1fr))] gap-4 p-1",children:R.map(u=>{const q=v.software[u.id]??0,I=o.includes(u.id),Y=q===0&&!I;return e.jsx(Us,{software:u,count:q,isSelected:I,isDisabled:Y,onToggle:()=>x(u.id),onInfoClick:()=>j(u)},u.id)})})})}),e.jsx(fe,{value:"filetypes",className:"mt-4",children:_?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(he,{})}):c.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No file types available"}):e.jsx("div",{className:"max-h-[460px] overflow-y-auto pr-2",children:e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-4 p-1",children:c.map(u=>{const q=v.file_types[u]??0,I=m.includes(u),Y=q===0&&!I;return e.jsx(Bs,{extension:u,count:q,isSelected:I,isDisabled:Y,onToggle:()=>S(u)},u)})})})})]}),e.jsx(Fe,{open:P,onOpenChange:M,type:A,data:$,allTechniques:U,onTechniqueClick:E})]})}function Lt({delivery:t,className:s,size:a="sm"}){const r=a==="sm"?"h-4 w-4":"h-5 w-5",n=[{key:"attachment",icon:cs,label:"Deliverable as attachment",inactive:"Not deliverable as attachment"},{key:"link",icon:Mt,label:"Deliverable as link",inactive:"Not deliverable as link"},{key:"body",icon:Ae,label:"Deliverable as body",inactive:"Not deliverable as body"}];return e.jsx(xt,{children:e.jsx("div",{className:X("flex items-center gap-1",s),children:n.map(({key:h,icon:o,label:x,inactive:m})=>{const S=t.includes(h);return e.jsxs(gt,{children:[e.jsx(jt,{asChild:!0,children:e.jsx("span",{className:X("cursor-default",S?"text-primary":"text-muted-foreground
2/30 cursor-not-allowed"),children:e.jsx(o,{className:r})})}),e.jsx(yt,{children:S?x:m})]},h)})})})}function Vs(t){const s=Math.floor(Date.now()/1e3)-2592e3;return t>s}function Gs(t){return new Date(t*1e3).toLocaleDateString()}function Ws({payloads:t,isLoading:s,searchTerm:a,customFilter:r,selectedTechniques:n,selectedGroups:h,selectedSoftware:o,selectedFileTypes:x,selectedPayloadId:m,onPayloadSelect:S,onEditPayload:D,onDeletePayload:_,isInTeam:y=!1}){const[P,M]=l.useState(null),[A,W]=l.useState(null),[$,C]=l.useState("desc"),U=p=>{A===p?$==="desc"?C("asc"):W(null):(W(p),C("desc"))},K=l.useCallback((p,j)=>p.metrics?j==="user"?p.metrics.user?.average?.delivered??-1:j==="team"?p.metrics.team?.average?.delivered??-1:p.metrics.global?.delivered??-1:-1,[]),F=l.useMemo(()=>y?!0:t.some(p=>p.metrics?.team!==void 0),[y,t]),i=l.useMemo(()=>{if(!t)return[];let p=[...t];if(r==="only"?p=p.filter(j=>j.custom):r==="exclude"&&(p=p.filter(j=>!j.custom)),a){const j=a.toLowerCase();p=p.filter(N=>N.name.toLowerCase().includes(j)||N.description?.toLowerCase().includes(j)||N.tags?.some(w=>w.toLowerCase().includes(j)))}return n.length>0&&(p=p.filter(j=>n.every(N=>j.techniques?.includes(N)))),h.length>0&&(p=p.filter(j=>h.every(N=>j.groups?.includes(N)))),o.length>0&&(p=p.filter(j=>o.every(N=>j.software?.includes(N)))),x.length>0&&(p=p.filter(j=>{const N=new Set([j.extension,...j.file_types||[]]);return x.every(w=>N.has(w))})),p.sort((j,N)=>{if(A){const d=K(j,A),b=K(N,A);if(d===-1&&b===-1)return 0;if(d===-1)return 1;if(b===-1)return-1;const L=$==="desc"?b-d:d-b;if(L!==0)return L}if(j.custom!==N.custom)return j.custom?-1:1;const w=j.added_epoch??0,R=N.added_epoch??0;return w!==R?R-w:j.name.localeCompare(N.name)}),p},[t,a,r,n,h,o,x,A,$,K]),[k,z]=l.useState(0),v=10,c=Math.ceil(i.length/v);l.useMemo(()=>{z(0)},[i.length]);const E=l.useMemo(()=>{const p=k*v;return i.slice(p,p+v)},[i,k]);return s?e.jsx(se,{children:e.jsx(ae,{className:"flex justify-center py-12",children:e.jsx(he,{})})}):e.jsxs(se,{children:[e.jsxs(ae,{className:"p-0",children:[e.jsxs(ws,{children:[e.jsx(bs,{children:e.jsxs(Ue,{children:[e.jsx(me,{className:"w-[48px] min-w-[48px]"}),e.jsx(me,{className:"min-w-[150px]",children:"Payload Name"}),e.jsx(me,{className:"w-[70px]"}),!m&&e.jsx(me,{className:F?"w-[180px]":"w-[130px]",title:"Deliverability rates: You / Team / Global",children:e.jsxs("div",{className:"flex items-center",children:[e.jsxs("button",{onClick:()=>U("user"),className:X("w-[52px] flex items-center gap-0.5 hover:text-primary transition-colors",A==="user"&&"text-primary"),title:"Sort by your deliverability",children:[e.jsx(st,{className:"h-3 w-3"}),A==="user"&&($==="desc"?e.jsx(we,{className:"h-3 w-3"}):e.jsx(qe,{className:"h-3 w-3"}))]}),F&&e.jsxs("button",{onClick:()=>U("team"),className:X("w-[52px] flex items-center gap-0.5 hover:text-primary transition-colors",A==="team"&&"text-primary"),title:"Sort by team deliverability",children:[e.jsx(je,{className:"h-3 w-3"}),A==="team"&&($==="desc"?e.jsx(we,{className:"h-3 w-3"}):e.jsx(qe,{className:"h-3 w-3"}))]}),e.jsxs("button",{onClick:()=>U("global"),className:X("w-[52px] flex items-center gap-0.5 hover:text-primary transition-colors",A==="global"&&"text-primary"),title:"Sort by global deliverability",children:[e.jsx(Ls,{className:"h-3 w-3"}),A==="global"&&($==="desc"?e.jsx(we,{className:"h-3 w-3"}):e.jsx(qe,{className:"h-3 w-3"}))]})]})}),e.jsx(me,{className:"w-[100px]",children:"Methods"}),e.jsx(me,{className:"w-[40px]"})]})}),e.jsx(Ns,{children:E.length===0?e.jsx(Ue,{children:e.jsx(ce,{colSpan:m?5:6,className:"text-center py-8",children:e.jsx("p",{className:"text-muted-foreground",children:"No payloads found"})})}):E.map(p=>e.jsxs(Ue,{className:X("cursor-pointer",m===p.recipe_id&&"bg-accent"),onClick:()=>S(p.recipe_id??p.id),children:[e.jsx(ce,{className:"p-2 w-[48px] min-w-[48px]",children:e.jsx(tt,{extension:p.extension,size:"md",className:"h-6 w-6"})}),e.jsx(ce,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:p.name}),p.custom&&(p.ownership==="user"?e.jsx("span",{title:"Owned by You",children:e.jsx(st,{className:"h-4 w-4 text-muted-foreground
2/50"})}):e.jsx("span",{title:"Team Owned",children:e.jsx(je,{className:"h-4 w-4 text-muted-foreground/50"})}))]})}),e.jsx(ce,{children:p.added_epoch&&Vs(p.added_epoch)&&e.jsx(H,{className:"bg-success/15 text-success border border-success/30 pointer-events-none text-[10px] font-semibold uppercase tracking-wide",title:`Added ${Gs(p.added_epoch)}`,children:"New"})}),!m&&e.jsx(ce,{children:e.jsx(ds,{metrics:p.metrics,isInTeam:F})}),e.jsx(ce,{children:e.jsx(Lt,{delivery:p.delivery||[]})}),e.jsx(ce,{children:p.deletable&&e.jsxs(Ht,{children:[e.jsx(Kt,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:j=>j.stopPropagation(),children:e.jsx(Fs,{className:"h-4 w-4"})})}),e.jsxs(Vt,{align:"end",children:[e.jsx(at,{onClick:j=>{j.stopPropagation(),D?.(p)},children:"Edit Payload"}),e.jsx(at,{className:"text-destructive",onClick:j=>{j.stopPropagation(),M(p)},children:"Delete Payload"})]})]})})]},p.recipe_id))})]}),e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:i.length>0?e.jsxs(e.Fragment,{children:["Showing ",k*v+1,"-",Math.min((k+1)*v,i.length)," ","of ",i.length," payload",i.length!==1?"s":""]}):"0 payloads"}),c>1&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{variant:"outline",size:"sm",onClick:()=>z(p=>Math.max(0,p-1)),disabled:k===0,children:e.jsx(Gt,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Page ",k+1," of ",c]}),e.jsx(G,{variant:"outline",size:"sm",onClick:()=>z(p=>Math.min(c-1,p+1)),disabled:k>=c-1,children:e.jsx(Wt,{className:"h-4 w-4"})})]})]})]}),e.jsx(Ss,{open:!!P,onOpenChange:p=>!p&&M(null),children:e.jsxs(Ts,{children:[e.jsxs(ks,{children:[e.jsx(Ps,{children:"Delete Payload"}),e.jsxs(Ms,{children:['Are you sure you want to delete "',P?.name,`"? This will remove it from all custom campaign templates, and you won't be able to recover it.`]})]}),e.jsxs(Ds,{children:[e.jsx(Es,{children:"Cancel"}),e.jsx(Os,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{P&&(_?.(P),M(null))},children:"Delete"})]})]})})]})}function Ke({text:t,label:s}){const[a,r]=l.useState(!1),n=async()=>{await navigator.clipboard.writeText(t),r(!0),V.success(`${s||"Text"} copied to clipboard`),setTimeout(()=>r(!1),2e3)};return e.jsxs("div",{className:"bg-muted/50 rounded px-3 py-2 cursor-pointer hover:bg-muted/70 transition-colors group flex items-center gap-2",onClick:n,title:`Click to copy ${s||t}`,children:[e.jsx("code",{className:"font-mono text-sm break-all flex-1",children:t}),a?e.jsx(Xt,{className:"h-3 w-3 text-green-500 flex-shrink-0"}):e.jsx(Cs,{className:"h-3 w-3 text-muted-foreground opacity-0 group-hover:opacity-100 flex-shrink-0 transition-opacity"})]})}function lt({payloadId:t,isExpanded:s,onExpand:a,onCollapse:r,onClose:n}){const[h,o]=l.useState(!1),[x,m]=l.useState(!1),[S,D]=l.useState(!1),[_,y]=l.useState(null),[P,M]=l.useState(!1),[A,W]=l.useState(null),[$,C]=l.useState(!1),[U,K]=l.useState(null),{data:F}=vt(),{data:i,isLoading:k}=J({queryKey:["payload","detail",t,{metrics_history:!0}],queryFn:()=>Q.get(t,{metrics_history:!0}),enabled:!!t}),{data:z=[]}=J({queryKey:["techniques"],queryFn:Q.getTechniques,staleTime:300*1e3}),{data:v=[]}=J({queryKey:["groups"],queryFn:Q.getGroups,staleTime:300*1e3}),{data:c=[]}=J({queryKey:["software"],queryFn:Q.getSoftware,staleTime:300*1e3}),E=d=>{const b=z.find(L=>L.id===d);b&&(y(b),D(!0))},p=d=>{const b=v.find(L=>L.id===d);b&&(W(b),M(!0))},j=d=>{const b=c.find(L=>L.id===d);b&&(K(b),C(!0))};if(!t)return null;if(k)return e.jsx(se,{className:X(s&&"min-h-[600px]"),children:e.jsx(ae,{className:"flex items-center justify-center py-12",children:e.jsx(he,{})})});if(!i)return e.jsx(se,{children:e.jsx(ae,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"Payload not found"})})});const N=async()=>{if(!(!i?.payload_id||h)){o(!0),V.loading("Preparing download...",{id:"payload-download"});try{const d=await Q.download(i.payload_id);if(d.type==="redirect")window.open(d.url,"_blank"),V.success(`Download started: ${d.filename}`,{id:"payload-download"});else{const b=URL.createObjectURL(d.blob),L=document.createElement("a");L.href=b,L.download=d.filename,document.body.appendChild(L),L.click(),document.body.removeChild(L),URL.revokeObjectURL(b),V.success(`Downloaded: ${d.filename}`,{id:"payload-download"})}}catch(d){console.error("Download error:",d),V.error("Failed to download payload",{id:"payload-download"})}finally{o(!1)}}},w=async()=>{const b=i.categories?.includes("custom")?`${window.location.origin}/app/payloads?id=${t}`:`${window.location.origin}/payloads?id=${t}`;try{await navigator.clipboard.writeText(b),V.success("Link copied to clipboard")}catch{V.error("Failed to copy link")}},R=i.name.split(".").pop()?.toLowerCase()||"";return e.jsxs(se,{className:X(s&&"min-h-[600px]"),children:[e.jsx(Qt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx(tt,{extension:R,size:"lg"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(Yt,{className:"text-lg truncate",title:i.name,children:i.name}),i.tags&&i.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:i.tags.map(d=>e.jsx(H,{variant:"secondary",className:"text-xs",children:d},d))})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[s?e.jsx(G,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(Ze,{className:"h-4 w-4"})}):e.jsx(G,{variant:"ghost",size:"icon",onClick:a,children:e.jsx(Xe,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",onClick:n,children:e.jsx(te,{className:"h-4 w-4"})})]})]})}),e.jsxs(ae,{className:X("space-y-6",!s&&"max-h-[calc(100vh-200px)] overflow-y-auto"),children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"Delivery Methods"}),e.jsx(Lt,{delivery:i.delivery||[],size:"md"})]}),i.description&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"Description"}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-line",children:i.description})]}),e.jsx(Ee,{}),i?.metrics_history&&e.jsx(us,{metricsHistory:i.metrics_history,userEmail:F?.primary_email,compact:!s}),s?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{}),e.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-6",children:[((i.groups?.length??0)>
20||(i.software?.length??0)>0||(i.file_types?.length??0)>0||(i.techniques?.length??0)>0)&&e.jsxs("div",{className:"p-4 bg-muted/10 rounded-lg border space-y-1",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:"Threat Info"}),i.groups&&i.groups.length>0&&e.jsxs("div",{className:"flex items-start gap-3 py-2",children:[e.jsx(je,{className:"h-4 w-4 text-muted-foreground mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Threat Actors"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:i.groups.map(d=>{const b=v.find(L=>L.id===d);return e.jsx(H,{variant:"outline",className:"text-xs cursor-pointer hover:bg-muted",onClick:()=>p(d),children:b?.name||d},d)})})]})]}),i.software&&i.software.length>0&&e.jsxs("div",{className:"flex items-start gap-3 py-2",children:[e.jsx(Re,{className:"h-4 w-4 text-muted-foreground mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Software"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:i.software.map(d=>{const b=c.find(L=>L.id===d);return e.jsx(H,{variant:"outline",className:"text-xs cursor-pointer hover:bg-muted",onClick:()=>j(d),children:b?.name||d},d)})})]})]}),i.file_types&&i.file_types.length>0&&e.jsxs("div",{className:"flex items-start gap-3 py-2",children:[e.jsx(ms,{className:"h-4 w-4 text-muted-foreground mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"File Types"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:i.file_types.map(d=>e.jsx(H,{variant:"secondary",className:"text-xs",children:d},d))})]})]}),i.techniques&&i.techniques.length>0&&e.jsxs("div",{className:"flex items-start gap-3 py-2",children:[e.jsx(hs,{className:"h-4 w-4 text-muted-foreground mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Attack Techniques"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:i.techniques.map(d=>{const b=z.find(L=>L.id===d);return e.jsx(H,{variant:"secondary",className:"text-xs cursor-pointer hover:bg-secondary/80",onClick:()=>E(d),children:b?.name||d},d)})})]})]})]}),i.image&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"Payload Structure"}),e.jsx("div",{className:"flex justify-center",children:e.jsx("img",{src:`data:image/png;base64,${i.image}`,alt:i.name,className:"max-h-64 rounded-lg border cursor-pointer hover:opacity-90",onClick:()=>{}})})]}),i.references&&i.references.length>0&&e.jsxs("div",{className:"overflow-hidden",children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"References"}),e.jsx("ul",{className:"space-y-1",children:i.references.map((d,b)=>e.jsx("li",{className:"overflow-hidden",children:e.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline inline-flex items-center gap-1 max-w-full",title:d,children:[e.jsx(nt,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:d})]})},b))})]})]}),e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"p-4 bg-muted/10 rounded-lg border",children:[e.jsx("h4",{className:"text-base font-medium mb-4",children:"Technical Details"}),e.jsxs("div",{className:"space-y-4",children:[i.hash&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ps,{className:"h-4 w-4 text-muted-foreground mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"MD5 Hash"}),e.jsx(Ke,{text:i.hash,label:"MD5 Hash"})]})]}),i.payload_id&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(rt,{className:"h-4 w-4 text-muted-foreground mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"Payload ID"}),e.jsx(Ke,{text:i.payload_id,label:"Payload ID"})]})]}),i.recipe_id&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(rt,{className:"h-4 w-4 text-muted-foreground mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"Recipe ID"}),e.jsx(Ke,{text:i.recipe_id,label:"Recipe ID"})]})]}),i.last_generated&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(_s,{className:"h-4 w-4 text-muted-foreground mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"Last Updated"}),e.jsxs("p",{className:"text-sm font-medium",children:[new Date(i.last_generated*1e3).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})," ","at"," ",new Date(i.last_generated*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})]})]})]})]})]})})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[i.groups&&i.groups.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"Threat Groups"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:i.groups.map(d=>{const b=v.find(L=>
2L.id===d);return e.jsx(H,{variant:"outline",className:"cursor-pointer hover:bg-muted",onClick:()=>p(d),children:b?.name||d},d)})})]}),i.software&&i.software.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"Software"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:i.software.map(d=>{const b=c.find(L=>L.id===d);return e.jsx(H,{variant:"outline",className:"cursor-pointer hover:bg-muted",onClick:()=>j(d),children:b?.name||d},d)})})]}),i.file_types&&i.file_types.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"File Types"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:i.file_types.map(d=>e.jsx(H,{variant:"outline",children:d},d))})]}),i.techniques&&i.techniques.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"Attack Techniques"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:i.techniques.map(d=>{const b=z.find(L=>L.id===d);return e.jsx(H,{variant:"outline",className:"cursor-pointer hover:bg-muted",onClick:()=>E(d),children:b?.name||d},d)})})]})]}),e.jsx(Ee,{}),i.references&&i.references.length>0&&e.jsxs("div",{className:"overflow-hidden",children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"References"}),e.jsx("ul",{className:"space-y-1",children:i.references.map((d,b)=>e.jsx("li",{className:"overflow-hidden",children:e.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline inline-flex items-center gap-1 max-w-full",title:d,children:[e.jsx(nt,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:d})]})},b))})]})]}),e.jsx(Ee,{}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(G,{onClick:N,className:"flex-1",disabled:h,children:[h?e.jsx(Je,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(qs,{className:"mr-2 h-4 w-4"}),h?"Downloading...":"Download"]}),e.jsx(G,{variant:"outline",onClick:w,children:e.jsx(fs,{className:"h-4 w-4"})}),e.jsx(G,{variant:"outline",onClick:()=>m(!0),title:"Quick send to validated email",children:e.jsx(Zt,{className:"h-4 w-4 text-yellow-500"})})]})]}),e.jsx(xs,{open:x,onOpenChange:m,payload:i?{payload_id:i.payload_id,recipe_id:i.recipe_id,name:i.name,description:i.description,delivery:i.delivery}:null}),e.jsx(Fe,{open:S,onOpenChange:D,type:"technique",data:_,allTechniques:z,onTechniqueClick:d=>y(d)}),e.jsx(Fe,{open:P,onOpenChange:M,type:"group",data:A}),e.jsx(Fe,{open:$,onOpenChange:C,type:"software",data:U})]})}function ot(t,s){(s==null||s>t.length)&&(s=t.length);for(var a=0,r=Array(s);a<s;a++)r[a]=t[a];return r}function Qs(t){if(Array.isArray(t))return t}function Ys(t,s,a){return(s=aa(s))in t?Object.defineProperty(t,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[s]=a,t}function Zs(t,s){var a=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(a!=null){var r,n,h,o,x=[],m=!0,S=!1;try{if(h=(a=a.call(t)).next,s!==0)for(;!(m=(r=h.call(a)).done)&&(x.push(r.value),x.length!==s);m=!0);}catch(D){S=!0,n=D}finally{try{if(!m&&a.return!=null&&(o=a.return(),Object(o)!==o))return}finally{if(S)throw n}}return x}}function Xs(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
3In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ct(t,s){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);s&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),a.push.apply(a,r)}return a}function dt(t){for(var s=1;s<arguments.length;s++){var a=arguments[s]!=null?arguments[s]:{};s%2?ct(Object(a),!0).forEach(function(r){Ys(t,r,a[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):ct(Object(a)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(a,r))})}return t}function Js(t,s){if(t==null)return{};var a,r,n=ea(t,s);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(t);for(r=0;r<h.length;r++)a=h[r],s.indexOf(a)===-1&&{}.propertyIsEnumerable.call(t,a)&&(n[a]=t[a])}return n}function ea(t,s){if(t==null)return{};var a={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(s.indexOf(r)!==-1)continue;a[r]=t[r]}return a}function ta(t,s){return Qs(t)||Zs(t,s)||ra(t,s)||Xs()}
3function sa(t,s){if(typeof t!="object"||!t)return t;var a=t[Symbol.toPrimitive];if(a!==void 0){var r=a.call(t,s);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(t)}function aa(t){var s=sa(t,"string");return typeof s=="symbol"?s:s+""}function ra(t,s){if(t){if(typeof t=="string")return ot(t,s);var a={}.toString.call(t).slice(8,-1);return a==="Object"&&t.constructor&&(a=t.constructor.name),a==="Map"||a==="Set"?Array.from(t):a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?ot(t,s):void 0}}function na(t,s,a){return s in t?Object.defineProperty(t,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[s]=a,t}function ut(t,s){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);s&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),a.push.apply(a,r)}return a}function mt(t){for(var s=1;s<arguments.length;s++){var a=arguments[s]!=null?arguments[s]:{};s%2?ut(Object(a),!0).forEach(function(r){na(t,r,a[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):ut(Object(a)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(a,r))})}return t}function ia(){for(var t=arguments.length,s=new Array(t),a=0;a<t;a++)s[a]=arguments[a];return function(r){return s.reduceRight(function(n,h){return h(n)},r)}}function ve(t){return function s(){for(var a=this,r=arguments.length,n=new Array(r),h=0;h<r;h++)n[h]=arguments[h];return n.length>=t.length?t.apply(this,n):function(){for(var o=arguments.length,x=new Array(o),m=0;m<o;m++)x[m]=arguments[m];return s.apply(a,[].concat(n,x))}}}function _e(t){return{}.toString.call(t).includes("Object")}function la(t){return!Object.keys(t).length}function Ne(t){return typeof t=="function"}function oa(t,s){return Object.prototype.hasOwnProperty.call(t,s)}function ca(t,s){return _e(s)||le("changeType"),Object.keys(s).some(function(a){return!oa(t,a)})&&le("changeField"),s}function da(t){Ne(t)||le("selectorType")}function ua(t){Ne(t)||_e(t)||le("handlerType"),_e(t)&&Object.values(t).some(function(s){return!Ne(s)})&&le("handlersType")}function ma(t){t||le("initialIsRequired"),_e(t)||le("initialType"),la(t)&&le("initialContent")}function ha(t,s){throw new Error(t[s]||t.default)}var pa={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},le=ve(ha)(pa),Oe={changes:ca,selector:da,handler:ua,initial:ma};function fa(t){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Oe.initial(t),Oe.handler(s);var a={current:t},r=ve(ja)(a,s),n=ve(ga)(a),h=ve(Oe.changes)(t),o=ve(xa)(a);function x(){var S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(D){return D};return Oe.selector(S),S(a.current)}function m(S){ia(r,n,h,o)(S)}return[x,m]}function xa(t,s){return Ne(s)?s(t.current):s}function ga(t,s){return t.current=mt(mt({},t.current),s),s}function ja(t,s,a){return Ne(s)?s(t.current):Object.keys(a).forEach(function(r){var n;return(n=s[r])===null||n===void 0?void 0:n.call(s,t.current[r])}),a}var ya={create:fa},va={paths:{vs:"https://cdn.jsdelivr.net/npm/[email protected]/min/vs"}};function wa(t){return function s(){for(var a=this,r=arguments.length,n=new Array(r),h=0;h<r;h++)n[h]=arguments[h];return n.length>=t.length?t.apply(this,n):function(){for(var o=arguments.length,x=new Array(o),m=0;m<o;m++)x[m]=arguments[m];return s.apply(a,[].concat(n,x))}}}function ba(t){return{}.toString.call(t).includes("Object")}function Na(t){return t||ht("configIsRequired"),ba(t)||ht("configType"),t.urls?(Ca(),{paths:{vs:t.urls.monacoBase}}):t}function Ca(){console.warn(qt.deprecation)}function Sa(t,s){throw new Error(t[s]||t.default)}var qt={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
4    You are using deprecated way of configuration.
5
6    Instead of using
7      monaco.config({ urls: { monacoBase: '...' } })
8    use
9      monaco.config({ paths: { vs: '...' } })
10
11    For more please check the link https://github.com/suren-atoyan/monaco-loader#config
12  `},ht=wa(Sa)(qt),Ta={config:Na},ka=function(){for(var s=arguments.length,a=new Array(s),r=0;r<s;r++)a[r]=arguments[r];return function(n){return a.reduceRight(function(h,o){return o(h)},n)}};
12function Ft(t,s){return Object.keys(s).forEach(function(a){s[a]instanceof Object&&t[a]&&Object.assign(s[a],Ft(t[a],s[a]))}),dt(dt({},t),s)}var Pa={type:"cancelation",msg:"operation is manually canceled"};function Ve(t){var s=!1,a=new Promise(function(r,n){t.then(function(h){return s?n(Pa):r(h)}),t.catch(n)});return a.cancel=function(){return s=!0},a}var Ma=["monaco"],Da=ya.create({config:va,isInitialized:!1,resolve:null,reject:null,monaco:null}),_t=ta(Da,2),Ce=_t[0],Ie=_t[1];function Ea(t){var s=Ta.config(t),a=s.monaco,r=Js(s,Ma);Ie(function(n){return{config:Ft(n.config,r),monaco:a}})}function Oa(){var t=Ce(function(s){var a=s.monaco,r=s.isInitialized,n=s.resolve;return{monaco:a,isInitialized:r,resolve:n}});if(!t.isInitialized){if(Ie({isInitialized:!0}),t.monaco)return t.resolve(t.monaco),Ve(Ge);if(window.monaco&&window.monaco.editor)return Rt(window.monaco),t.resolve(window.monaco),Ve(Ge);ka(La,Fa)(_a)}return Ve(Ge)}function La(t){return document.body.appendChild(t)}function qa(t){var s=document.createElement("script");return t&&(s.src=t),s}function Fa(t){var s=Ce(function(r){var n=r.config,h=r.reject;return{config:n,reject:h}}),a=qa("".concat(s.config.paths.vs,"/loader.js"));return a.onload=function(){return t()},a.onerror=s.reject,a}function _a(){var t=Ce(function(a){var r=a.config,n=a.resolve,h=a.reject;return{config:r,resolve:n,reject:h}}),s=window.require;s.config(t.config),s(["vs/editor/editor.main"],function(a){var r=a.m||a;Rt(r),t.resolve(r)},function(a){t.reject(a)})}function Rt(t){Ce().monaco||Ie({monaco:t})}function Ra(){return Ce(function(t){var s=t.monaco;return s})}var Ge=new Promise(function(t,s){return Ie({resolve:t,reject:s})}),At={config:Ea,init:Oa,__getMonacoInstance:Ra},Aa={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},We=Aa,za={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Ia=za;function $a({children:t}){return ge.createElement("div",{style:Ia.container},t)}var Ua=$a,Ba=Ua;function Ha({width:t,height:s,isEditorReady:a,loading:r,_ref:n,className:h,wrapperProps:o}){return ge.createElement("section",{style:{...We.wrapper,width:t,height:s},...o},!a&&ge.createElement(Ba,null,r),ge.createElement("div",{ref:n,style:{...We.fullWidth,...!a&&We.hide},className:h}))}var Ka=Ha,zt=l.memo(Ka);function Va(t){l.useEffect(t,[])}var It=Va;function Ga(t,s,a=!0){let r=l.useRef(!0);l.useEffect(r.current||!a?()=>{r.current=!1}:t,s)}var Z=Ga;function be(){}function xe(t,s,a,r){return Wa(t,r)||Qa(t,s,a,r)}function Wa(t,s){return t.editor.getModel($t(t,s))}function Qa(t,s,a,r){return t.editor.createModel(s,a,r?$t(t,r):void 0)}function $t(t,s){return t.Uri.parse(s)}function Ya({original:t,modified:s,language:a,originalLanguage:r,modifiedLanguage:n,originalModelPath:h,modifiedModelPath:o,keepCurrentOriginalModel:x=!1,keepCurrentModifiedModel:m=!1,theme:S="light",loading:D="Loading...",options:_={},height:y="100%",width:P="100%",className:M,wrapperProps:A={},beforeMount:W=be,onMount:$=be}){let[C,U]=l.useState(!1),[K,F]=l.useState(!0),i=l.useRef(null),k=l.useRef(null),z=l.useRef(null),v=l.useRef($),c=l.useRef(W),E=l.useRef(!1);It(()=>{let w=At.init();return w.then(R=>(k.current=R)&&F(!1)).catch(R=>R?.type!=="cancelation"&&console.error("Monaco initialization: error:",R)),()=>i.current?N():w.cancel()}),Z(()=>{if(i.current&&k.current){let w=i.current.getOriginalEditor(),R=xe(k.current,t||"",r||a||"text",h||"");R!==w.getModel()&&w.setModel(R)}},[h],C),Z(()=>{if(i.current&&k.current){let w=i.current.getModifiedEditor(),R=xe(k.current,s||"",n||a||"text",o||"");R!==w.getModel()&&w.setModel(R)}},[o],C),Z(()=>{let w=i.current.getModifiedEditor();w.getOption(k.current.editor.EditorOption.readOnly)?w.setValue(s||""):s!==w.getValue()&&(w.executeEdits("",[{range:w.getModel().getFullModelRange(),text:s||"",forceMoveMarkers:!0}]),w.pushUndoStop())},[s],C),Z(()=>{i.current?.getModel()?.original.setValue(t||"")},[t],C),Z(()=>{let{original:w,modified:R}=i.current.getModel();k.current.editor.setModelLanguage(w,r||a||"text"),k.current.editor.setModelLanguage(R,n||a||"text")},[a,r,n],C),Z(()=>{k.current?.editor.setTheme(S)},[S],C),Z(()=>{i.current?.updateOptions(_)},[_],C);let p=l.useCallback(()=>
12{if(!k.current)return;c.current(k.current);let w=xe(k.current,t||"",r||a||"text",h||""),R=xe(k.current,s||"",n||a||"text",o||"");i.current?.setModel({original:w,modified:R})},[a,s,n,t,r,h,o]),j=l.useCallback(()=>{!E.current&&z.current&&(i.current=k.current.editor.createDiffEditor(z.current,{automaticLayout:!0,..._}),p(),k.current?.editor.setTheme(S),U(!0),E.current=!0)},[_,S,p]);l.useEffect(()=>{C&&v.current(i.current,k.current)},[C]),l.useEffect(()=>{!K&&!C&&j()},[K,C,j]);function N(){let w=i.current?.getModel();x||w?.original?.dispose(),m||w?.modified?.dispose(),i.current?.dispose()}return ge.createElement(zt,{width:P,height:y,isEditorReady:C,loading:D,_ref:z,className:M,wrapperProps:A})}var Za=Ya;l.memo(Za);function Xa(t){let s=l.useRef();return l.useEffect(()=>{s.current=t},[t]),s.current}var Ja=Xa,Le=new Map;function er({defaultValue:t,defaultLanguage:s,defaultPath:a,value:r,language:n,path:h,theme:o="light",line:x,loading:m="Loading...",options:S={},overrideServices:D={},saveViewState:_=!0,keepCurrentModel:y=!1,width:P="100%",height:M="100%",className:A,wrapperProps:W={},beforeMount:$=be,onMount:C=be,onChange:U,onValidate:K=be}){let[F,i]=l.useState(!1),[k,z]=l.useState(!0),v=l.useRef(null),c=l.useRef(null),E=l.useRef(null),p=l.useRef(C),j=l.useRef($),N=l.useRef(),w=l.useRef(r),R=Ja(h),d=l.useRef(!1),b=l.useRef(!1);It(()=>{let u=At.init();return u.then(q=>(v.current=q)&&z(!1)).catch(q=>q?.type!=="cancelation"&&console.error("Monaco initialization: error:",q)),()=>c.current?re():u.cancel()}),Z(()=>{let u=xe(v.current,t||r||"",s||n||"",h||a||"");u!==c.current?.getModel()&&(_&&Le.set(R,c.current?.saveViewState()),c.current?.setModel(u),_&&c.current?.restoreViewState(Le.get(h)))},[h],F),Z(()=>{c.current?.updateOptions(S)},[S],F),Z(()=>{!c.current||r===void 0||(c.current.getOption(v.current.editor.EditorOption.readOnly)?c.current.setValue(r):r!==c.current.getValue()&&(b.current=!0,c.current.executeEdits("",[{range:c.current.getModel().getFullModelRange(),text:r,forceMoveMarkers:!0}]),c.current.pushUndoStop(),b.current=!1))},[r],F),Z(()=>{let u=c.current?.getModel();u&&n&&v.current?.editor.setModelLanguage(u,n)},[n],F),Z(()=>{x!==void 0&&c.current?.revealLine(x)},[x],F),Z(()=>{v.current?.editor.setTheme(o)},[o],F);let L=l.useCallback(()=>{if(!(!E.current||!v.current)&&!d.current){j.current(v.current);let u=h||a,q=xe(v.current,r||t||"",s||n||"",u||"");c.current=v.current?.editor.create(E.current,{model:q,automaticLayout:!0,...S},D),_&&c.current.restoreViewState(Le.get(u)),v.current.editor.setTheme(o),x!==void 0&&c.current.revealLine(x),i(!0),d.current=!0}},[t,s,a,r,n,h,S,D,_,o,x]);l.useEffect(()=>{F&&p.current(c.current,v.current)},[F]),l.useEffect(()=>{!k&&!F&&L()},[k,F,L]),w.current=r,l.useEffect(()=>{F&&U&&(N.current?.dispose(),N.current=c.current?.onDidChangeModelContent(u=>{b.current||U(c.current.getValue(),u)}))},[F,U]),l.useEffect(()=>{if(F){let u=v.current.editor.onDidChangeMarkers(q=>{let I=c.current.getModel()?.uri;if(I&&q.find(Y=>Y.path===I.path)){let Y=v.current.editor.getModelMarkers({resource:I});K?.(Y)}});return()=>{u?.dispose()}}return()=>{}},[F,K]);function re(){N.current?.dispose(),y?_&&Le.set(h,c.current.saveViewState()):c.current.getModel()?.dispose(),c.current.dispose()}return ge.createElement(zt,{width:P,height:M,isEditorReady:F,loading:m,_ref:E,className:A,wrapperProps:W})}var tr=er,sr=l.memo(tr),ar=sr;const rr=`<!doctype html>
13<html>
14
15<head>
16  <meta name="viewport" content="width=device-width, initial-scale=1.0">
17  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
18  <title>Your delivr.to content.</title>
19  <style>
20    @media only screen and (max-width: 620px) {
21      table.body h1 {
22        font-size: 28px !important;
23        margin-bottom: 10px !important;
24      }
25
26      table.body p,
27      table.body ul,
28      table.body ol,
29      table.body td,
30      table.body span,
31      table.body a {
32        font-size: 16px !important;
33      }
34
35      table.body .wrapper,
36      table.body .article {
37        padding: 10px !important;
38      }
39
40      table.body .content {
41        padding: 0 !important;
42      }
43
44      table.body .container {
45        padding: 0 !important;
46        width: 100% !important;
47      }
48
49      table.body .main {
50        border-left-width: 0 !important;
51        border-radius: 0 !important;
52        border-right-width: 0 !important;
53      }
54
55      table.body .btn table {
56        width: 100% !important;
57      }
58
59      table.body .btn a {
60        width: 100% !important;
61      }
62
63      table.body .img-responsive {
64        height: auto !important;
65        max-width: 100% !important;
66        width: auto !important;
67      }
68    }
69
70    @media all {
71      .ExternalClass {
72        width: 100%;
73      }
74
75      .ExternalClass,
76      .ExternalClass p,
77      .ExternalClass span,
78      .ExternalClass font,
79      .ExternalClass td,
80      .ExternalClass div {
81        line-height: 100%;
82      }
83
84      .apple-link a {
85        color: inherit !important;
86        font-family: inherit !important;
87        font-size: inherit !important;
88        font-weight: inherit !important;
89        line-height: inherit !important;
90        text-decoration: none !important;
91      }
92
93      #MessageViewBody a {
94        color: inherit;
95        text-decoration: none;
96        font-size: inherit;
97        font-family: inherit;
98        font-weight: inherit;
99        line-height: inherit;
100      }
101
102      .btn-primary table td:hover {
103        background-color: #34495e !important;
104      }
105
106      .btn-primary a:hover {
107        background-color: #34495e !important;
108        border-color: #34495e !important;
109      }
110    }
111  </style>
112</head>
113
114<body
115  style="background-color: #f6f6f6; font-family: sans-serif; -webkit-font-smoothing: antialiased; font-size: 14px; line-height: 1.4; margin: 0; padding: 0; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;">
116  <table role="presentation" border="0" cellpadding="0" cellspacing="0" class="body"
117    style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #f6f6f6; width: 100%;"
118    width="100%" bgcolor="#f6f6f6">
119    <tr>
120      <td style="font-family: sans-serif; font-size: 14px; vertical-align: top;" valign="top">&nbsp;</td>
121      <td class="container"
122        style="font-family: sans-serif; font-size: 14px; vertical-align: top; display: block; max-width: 580px; padding: 10px; width: 580px; margin: 0 auto;"
123        width="580" valign="top">
124        <div class="content"
125          style="box-sizing: border-box; display: block; margin: 0 auto; max-width: 580px; padding: 10px;">
126
127          <!-- START CENTERED WHITE CONTAINER -->
128          <table role="presentation" class="main"
129            style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; background: #ffffff; border-radius: 3px; width: 100%;"
130            width="100%">
131
132            <!-- START MAIN CONTENT AREA -->
133            <tr>
134              <td class="wrapper"
135                style="font-family: sans-serif; font-size: 14px; vertical-align: top; box-sizing: border-box; padding: 20px;"
136                valign="top">
137                <table role="presentation" border="0" cellpadding="0" cellspacing="0"
138                  style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;"
139                  width="100%">
140                  <tr>
141                    <br>
142                    <td style="font-family: sans-serif; font-size: 14px; vertical-align: top;" valign="top">
143                      <p
144                        style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; margin-bottom: 15px;">
145                        To #{RECIPIENT_EMAIL},<br/><br/>
146                        This is a sample HTML payload. Edit this content to create your custom body payload for testing.<br/><br/>
147                        Best regards,<br/>
148                        delivr.to
149                      </p>
150                    </td>
151                  </tr>
152                </table>
153              </td>
154            </tr>
155
156            <!-- END MAIN CONTENT AREA -->
157          </table>
158          <!-- END CENTERED WHITE CONTAINER -->
159        </div>
160      </td>
161      <td style="font-family: sans-serif; font-size: 14px; vertical-align: top;" valign="top">&nbsp;</td>
162    </tr>
163  </table>
164</body>
165</html>`;function pt(){return rr}function nr({value:t,onChange:s}){const{resolvedTheme:a}=Jt(),r=l.useRef(null),[n,h]=l.useState("none"),[o,x]=l.useState("light"),m=`
166    <style id="preview-dark-mode">
167      html, body {
168        background-color: #1a1a1a !important;
169        color: #e0e0e0 !important;
170      }
171      * {
172        border-color: #404040 !important;
173      }
174      a {
175        color: #6db3f2 !important;
176      }
177      table, td, th {
178        background-color: inherit !important;
179      }
180      .main, [class*="container"], [class*="wrapper"], [class*="content"] {
181        background-color: #2d2d2d !important;
182      }
183      img {
184        opacity: 0.9;
185      }
186    </style>
187  `;l.useEffect(()=>{if(r.current){const P=r.current.contentDocument;if(P){if(P.open(),o==="dark"){const M=t.includes("</head>")?t.replace("</head>",`${m}</head>`):`${m}${t}`;P.write(M)}else P.write(t);P.close()}}},[t,n,o]);const S=P=>{s(P||"")},D=P=>{h(M=>M===P?"none":P)},_=n==="none"||n==="editor",y=n==="none"||n==="preview";return e.jsxs("div",{className:"flex flex-col lg:flex-row gap-4 h-[560px]",children:[_&&e.jsxs("div",{className:"min-w-0 border rounded-lg overflow-hidden bg-background flex-1",children:[e.jsxs("div",{className:"h-8 px-3 flex items-center justify-between border-b bg-muted/50",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"HTML Editor"}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>D("editor"),title:n==="editor"?"Restore":"Expand",children:n==="editor"?e.jsx(Ze,{className:"h-3.5 w-3.5"}):e.jsx(Xe,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"h-[calc(100%-2rem)]",children:e.jsx(ar,{height:"100%",defaultLanguage:"html",value:t,onChange:S,theme:a==="dark"?"vs-dark":"light",loading:e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(wt,{size:32,color:"hsl(var(--primary))"})}),options:{minimap:{enabled:!1},fontSize:13,lineNumbers:"on",wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0,tabSize:2,insertSpaces:!0,formatOnPaste:!0,padding:{top:8}}})})]}),y&&e.jsxs("div",{className:"min-w-0 border rounded-lg overflow-hidden bg-background flex-1",children:[e.jsxs("div",{className:"h-8 px-3 flex items-center justify-between border-b bg-muted/50",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Preview"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(G,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>x(o==="light"?"dark":"light"),title:o==="light"?"Dark mode preview":"Light mode preview",children:o==="light"?e.jsx(es,{className:"h-3.5 w-3.5"}):e.jsx(ts,{className:"h-3.5 w-3.5"})}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>D("preview"),title:n==="preview"?"Restore":"Expand",children:n==="preview"?e.jsx(Ze,{className:"h-3.5 w-3.5"}):e.jsx(Xe,{className:"h-3.5 w-3.5"})})]})]}),e.jsx("div",{className:`h-[calc(100%-2rem)] transition-colors ${o==="dark"?"bg-[#1a1a1a]":"bg-white"}`,children:e.jsx("iframe",{ref:r,title:"HTML Preview",className:"w-full h-full border-0",sandbox:"allow-same-origin"})})]})]})}const ir=157286400,lr=1048576;function or({open:t,onOpenChange:s,onSuccess:a}){const r=ft(),[n,h]=l.useState("upload"),[o,x]=l.useState(null),[m,S]=l.useState(pt()),[D,_]=l.useState(""),[y,P]=l.useState(""),[M,A]=l.useState([]),[W,$]=l.useState(""),[C,U]=l.useState([]),[K,F]=l.useState(""),[i,k]=l.useState(""),[z,v]=l.useState({attachment:!0,link:!1,body:!1}),[c,E]=l.useState(!1),[p,j]=l.useState(""),[N,w]=l.useState(!1),[R,d]=l.useState(!0),b=f=>{try{const O=new URL(f);return O.protocol==="http:"||O.protocol==="https:"}catch{return!1}},L=f=>{if((f.key==="Enter"||f.key===",")&&K.trim()){f.preventDefault();const O=K.trim().replace(/,/g,"");if(!b(O)){k("Please enter a valid URL (http:// or https://)");return}if(C.includes(O)){k("This reference has already been added");return}U([...C,O]),F(""),k("")}},re=f=>{U(C.filter(O=>O!==f))},u=f=>{const O=f.target.files?.[0];O&&q(O)},q=f=>{if(f.size>ir){V.error("File size exceeds 150MB limit");return}x(f),D||_(f.name)},I=f=>{f.preventDefault(),f.stopPropagation(),w(!0)},Y=f=>{f.preventDefault(),f.stopPropagation(),w(!1)},Se=f=>{f.preventDefault(),f.stopPropagation(),w(!1);const O=f.dataTransfer.files?.[0];O&&q(O)},Te=f=>{if((f.key==="Enter"||f.key===",")&&W.trim()){f.preventDefault();const O=W.trim().replace(/,/g,"");O&&!M.includes(O)&&A([...M,O]),$("")}},ke=f=>{A(M.filter(O=>O!==f))},Pe=async()=>{const f=[];if(z.attachment&&f.push("attachment"),z.link&&f.push("link"),z.body&&f.push("body"),n==="html"){if(!m.trim()){V.error("Please enter some HTML content");return}const O=new Blob([m]).size;if(O>lr){V.error(`HTML content exceeds 1MB limit (${(O/(1024*1024)).toFixed(2)} MB)`);return}if(!D.trim()){V.error("Please provide a name for your payload");return}E(!0);try{j("Creating body payload...");const ne=btoa(encodeURIComponent(m).replace(/%([0-9A-F]{2})/g,(De,ye)=>String.fromCharCode(parseInt(ye,16))));let ie=D.trim();ie.toLowerCase().endsWith(".html")||(ie+=".html");const ue=await Q.addCustomPayload({content:ne,filename:ie,description:y||void 0,tags:M.length>0?M.join(","):void 0,references:C.length>0?C.join(","):void 0,delivery:f.length>0?f.join(","):"body"});await r.invalidateQueries({queryKey:["payloads"]}
187),V.success(ue.id?`Body payload created (ID: ${ue.id})`:"Body payload created successfully"),a?.(),s(!1),Me()}catch{V.error("Failed to create body payload")}finally{E(!1),j("")}}else{if(!o)return;E(!0);try{const O=D.trim()||o.name;j("Getting upload URL...");const{upload_url:ne,fields:ie,upload_id:ue,object_key:De}=await Q.getUploadUrl(O,o.size);j("Uploading file..."),await Q.uploadToS3(ne,ie,o),j("Finalizing...");const ye=await Q.confirmUpload({upload_id:ue,object_key:De,description:y||void 0,tags:M.length>0?M.join(","):void 0,references:C.length>0?C.join(","):void 0,delivery:f.length>0?f.join(","):void 0});await r.invalidateQueries({queryKey:["payloads"]}),V.success(ye.message||"Payload uploaded successfully"),a?.(),s(!1),Me()}catch{V.error("Failed to upload payload")}finally{E(!1),j("")}}},Me=()=>{h("upload"),x(null),S(pt()),_(""),P(""),A([]),$(""),U([]),F(""),k(""),v({attachment:!0,link:!1,body:!1}),d(!0)};return c?e.jsx(Qe,{open:t,onOpenChange:()=>{},children:e.jsx(Ye,{className:"max-w-md",hideCloseButton:!0,onInteractOutside:f=>f.preventDefault(),onEscapeKeyDown:f=>f.preventDefault(),children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 space-y-6",children:[e.jsx(wt,{size:80,color:"hsl(var(--primary))"}),e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("h3",{className:"text-lg font-semibold",children:n==="html"?"Creating Body Payload":"Uploading Payload"}),e.jsx("p",{className:"text-muted-foreground",children:p||"Processing..."}),n==="upload"&&o&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[o.name," (",(o.size/(1024*1024)).toFixed(2)," MB)"]}),n==="html"&&D&&e.jsx("p",{className:"text-sm text-muted-foreground",children:D.endsWith(".html")?D:`${D}.html`})]})]})})}):e.jsx(Qe,{open:t,onOpenChange:s,children:e.jsxs(Ye,{className:`max-h-[90vh] overflow-hidden flex flex-col transition-all duration-200 ${n==="html"?"max-w-6xl":"max-w-2xl"}`,children:[e.jsx(bt,{className:"flex-shrink-0",children:e.jsx(Nt,{children:"Add Custom Payload"})}),e.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0",children:[e.jsxs(kt,{value:n,onValueChange:f=>{const O=f;h(O),O==="html"?(v({attachment:!1,link:!1,body:!0}),d(!1)):(v({attachment:!0,link:!1,body:!1}),d(!0))},className:"w-full",children:[e.jsxs(Pt,{className:"grid w-full grid-cols-2",children:[e.jsxs(pe,{value:"upload",className:"flex items-center gap-2",children:[e.jsx(He,{className:"h-4 w-4"}),"File Upload"]}),e.jsxs(pe,{value:"html",className:"flex items-center gap-2",children:[e.jsx(it,{className:"h-4 w-4"}),"HTML Editor"]})]}),e.jsx(fe,{value:"upload",className:"mt-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(ee,{children:"Payload File"}),e.jsx("div",{className:`h-48 border-2 border-dashed rounded-lg p-6 flex flex-col items-center justify-center text-center transition-colors ${N?"border-primary bg-primary/5":"border-border hover:border-muted-foreground"}`,onDragOver:I,onDragLeave:Y,onDrop:Se,children:o?e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx("span",{className:"font-medium",children:o.name}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",(o.size/1024).toFixed(1)," KB)"]}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>x(null),children:e.jsx(te,{className:"h-4 w-4"})})]}):e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(He,{className:`h-8 w-8 mx-auto mb-2 ${N?"text-primary":"text-muted-foreground"}`}),e.jsx("p",{className:`text-sm ${N?"text-primary":"text-muted-foreground"}`,children:N?"Drop file here":"Click to upload or drag and drop"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Max file size: 150MB"}),e.jsx("input",{type:"file",className:"hidden",onChange:u})]})})]})}),e.jsxs(fe,{value:"html",className:"mt-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground flex items-center gap-1.5 mb-3",children:["Create an HTML body payload with live preview. Max size: 1MB",e.jsx(xt,{children:e.jsxs(gt,{children:[e.jsx(jt,{asChild:!0,children:e.jsx(ze,{className:"h-3.5 w-3.5 text-muted-foreground cursor-help"})}),e.jsxs(yt,{children:["Check the"," ",e.jsx("a",{href:"https://docs.delivr.to/docs/advanced_usage/body_payload_customisation.html",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"docs"})," ","for body payload customisation options"]})]})})]}),e.jsx(nr,{value:m,onChange:S})]})]}
187),e.jsxs(Ct,{open:R,onOpenChange:d,className:"border-t mt-4",children:[e.jsxs(St,{className:"flex items-center justify-between w-full py-3 text-sm font-medium hover:text-primary transition-colors",children:[e.jsx("span",{children:"Metadata & Options"}),e.jsx(we,{className:`h-4 w-4 transition-transform duration-200 ${R?"rotate-180":""}`})]}),e.jsxs(Tt,{className:"space-y-6 pb-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ee,{htmlFor:"name",children:["Name",n==="html"&&" *"]}),e.jsx(de,{id:"name",value:D,onChange:f=>_(f.target.value),placeholder:n==="html"?"Payload name (required)":"Payload name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ee,{children:"Delivery Methods"}),e.jsxs("div",{className:"flex items-center gap-4 pt-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Be,{checked:z.attachment,onCheckedChange:f=>v(O=>({...O,attachment:!!f}))}),"Attachment"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Be,{checked:z.link,onCheckedChange:f=>v(O=>({...O,link:!!f}))}),"Link"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Be,{checked:z.body,onCheckedChange:f=>v(O=>({...O,body:!!f}))}),"Body"]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ee,{htmlFor:"description",children:"Description"}),e.jsx(Dt,{id:"description",value:y,onChange:f=>P(f.target.value),placeholder:"Describe this payload...",rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ee,{htmlFor:"tags",children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:M.map(f=>e.jsxs(H,{variant:"secondary",className:"gap-1",children:[f,e.jsx("button",{onClick:()=>ke(f),className:"ml-1 hover:text-destructive",children:e.jsx(te,{className:"h-3 w-3"})})]},f))}),e.jsx(de,{id:"tags",value:W,onChange:f=>$(f.target.value),onKeyDown:Te,placeholder:"Add tags (press Enter or comma to add)"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ee,{htmlFor:"references",children:"References"}),e.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:C.map(f=>e.jsxs(H,{variant:"outline",className:"gap-1 max-w-full",children:[e.jsx(Mt,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{className:"truncate max-w-[200px]",title:f,children:f}),e.jsx("button",{onClick:()=>re(f),className:"ml-1 hover:text-destructive flex-shrink-0",children:e.jsx(te,{className:"h-3 w-3"})})]},f))}),e.jsx(de,{id:"references",value:K,onChange:f=>{F(f.target.value),k("")},onKeyDown:L,placeholder:"Add reference URLs (press Enter or comma to add)",className:i?"border-destructive":""}),i&&e.jsx("p",{className:"text-xs text-destructive",children:i})]})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 flex-shrink-0",children:[e.jsx(G,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(G,{onClick:Pe,disabled:n==="upload"?!o:!m.trim()||!D.trim(),children:n==="upload"?e.jsxs(e.Fragment,{children:[e.jsx(He,{className:"mr-2 h-4 w-4"}),"Upload Payload"]}):e.jsxs(e.Fragment,{children:[e.jsx(it,{className:"mr-2 h-4 w-4"}),"Create Body Payload"]})})]})]})})}function cr({open:t,onOpenChange:s,payload:a,onSuccess:r}){const[n,h]=l.useState(""),[o,x]=l.useState(""),[m,S]=l.useState([]),[D,_]=l.useState(""),[y,P]=l.useState([]),[M,A]=l.useState(""),[W,$]=l.useState(!1),[C,U]=l.useState(!1);l.useEffect(()=>{t&&a?.recipe_id&&($(!0),Q.get(a.recipe_id).then(c=>{h(c.name||""),x(c.description||""),S(c.tags||[]),P(c.references||[])}).catch(c=>{console.error("Failed to load payload details:",c),V.error("Failed to load payload details")}).finally(()=>{$(!1)}))},[t,a?.recipe_id]);const K=c=>{if((c.key==="Enter"||c.key===",")&&D.trim()){c.preventDefault();const E=D.trim().replace(/,/g,"");E&&!m.includes(E)&&S([...m,E]),_("")}},F=c=>{S(m.filter(E=>E!==c))},i=c=>{if(c.key==="Enter"&&M.trim()){c.preventDefault();const E=M.trim();E&&!y.includes(E)&&P([...y,E]),A("")}},k=c=>{P(y.filter(E=>E!==c))},z=async()=>{if(a?.recipe_id){U(!0);try{await Q.update(a.recipe_id,{filename:n||void 0,description:o||void 0,tags:m.length>0?m.join(","):void 0,references:y.length>0?y.join(","):void 0}),V.success("Payload updated successfully"),r?.(),s(!1)}catch(c){console.error("Update error:",c),V.error("Failed to update payload")}finally{U(!1)}}},v=()=>{h(""),x(""),S([]),_(""),P([]),A("")};return l.useEffect(()=>{t||v()},[t]),e.jsx(Qe,{open:t,onOpenChange:s,children:e.jsxs(Ye,{className:"max-w-2xl",children:[e.jsx(bt,{children:e.jsx(Nt,{children:"Edit Payload"})}),W?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Je,{className:"h-8 w-8 animate-spin text-primary"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ee,{htmlFor:"edit-name",children:"Name"}),e.jsx(de,{id:"edit-name",value:n,onChange:c=>h(c.target.value),placeholder:"Payload name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ee,{htmlFor:"edit-description",children:"Description"}),e.jsx(Dt,{id:"edit-description",value:o,onChange:c=>x(c.target.value),placeholder:"Describe this payload...",rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ee,{htmlFor:"edit-tags",children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:m.map(c=>e.jsxs(H,{variant:"secondary",className:"gap-1",children:[c,e.jsx("button",{onClick:()=>F(c),className:"ml-1 hover:text-destructive",children:e.jsx(te,{className:"h-3 w-3"})})]},c))}),e.jsx(de,{id:"edit-tags",value:D,onChange:c=>_(c.target.value),onKeyDown:K,placeholder:"Add tags (press Enter or comma to add)"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ee,{htmlFor:"edit-references",children:"References"}),e.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:y.map(c=>e.jsxs(H,{variant:"outline",className:"gap-1 max-w-full",children:[e.jsx("span",{className:"truncate max-w-[300px]",title:c,children:c}),e.jsx("button",{onClick:()=>k(c),className:"ml-1 hover:text-destructive flex-shrink-0",children:e.jsx(te,{className:"h-3 w-3"})})]},c))}),e.jsx(de,{id:"edit-references",value:M,onChange:c=>A(c.target.value),onKeyDown:i,placeholder:"Add reference URL (press Enter to add)"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(G,{onClick:z,disabled:C,children:C?e.jsxs(e.Fragment,{children:[e.jsx(Je,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"mr-2 h-4 w-4"}),"Save Changes"]})})]})]})]})})}function Ur(){vs("Payloads"),ss();const{data:t}=vt(),s=ft(),[a,r]=Bt(),n=t?.subscription_status==="Enterprise",[h,o]=l.useState(!1),[x,m]=l.useState(!1),[S,D]=l.useState([]),[_,y]=l.useState(!1),[P,M]=l.useState(null),[A,W]=l.useState(!1),$=js(),{data:C=[],isLoading:U,refetch:K}=J({queryKey:["payloads"],queryFn:()=>Q.list()}),{data:F=[]}=J({queryKey:["techniques"],queryFn:Q.getTechniques}),{data:i=[]}=J({queryKey:["groups"],queryFn:Q.getGroups}),{data:k=[]}=J({queryKey:["software"],queryFn:Q.getSoftware}),z=l.useMemo(()=>gs(C),[C]),v=a.get("id")||null,c=a.get("search")||"",E=a.get("custom")||"include",p=a.get("techniques")?.split(",").filter(
187Boolean)||[],j=a.get("groups")?.split(",").filter(Boolean)||[],N=a.get("software")?.split(",").filter(Boolean)||[],w=a.get("filetypes")?.split(",").filter(Boolean)||[],R=a.get("tab")||"techniques",d=a.get("collapsed")==="true",b=a.get("expanded")==="true",[L,re]=l.useState(c),u=g=>{const T=new URLSearchParams(a);Object.entries(g).forEach(([B,oe])=>{oe===null||oe===""?T.delete(B):T.set(B,oe)}),r(T,{replace:!0})},q=g=>{u({id:g})},I=g=>{re(g);const T=setTimeout(()=>{u({search:g||null})},300);return()=>clearTimeout(T)},Y=g=>{u({custom:g==="include"?null:g})},Se=g=>{const T=p.includes(g)?p.filter(B=>B!==g):[...p,g];u({techniques:T.length>0?T.join(","):null})},Te=g=>{const T=j.includes(g)?j.filter(B=>B!==g):[...j,g];u({groups:T.length>0?T.join(","):null})},ke=g=>{const T=N.includes(g)?N.filter(B=>B!==g):[...N,g];u({software:T.length>0?T.join(","):null})},Pe=g=>{const T=w.includes(g)?w.filter(B=>B!==g):[...w,g];u({filetypes:T.length>0?T.join(","):null})},Me=g=>{u({tab:g==="techniques"?null:g})},f=()=>{u({collapsed:d?null:"true"})},O=()=>{u({expanded:b?null:"true"})},ne=p.length>0||j.length>0||N.length>0||w.length>0,ie=l.useMemo(()=>{let g=C;if(E==="only"?g=g.filter(T=>T.is_custom):E==="exclude"&&(g=g.filter(T=>!T.is_custom)),c){const T=c.toLowerCase();g=g.filter(B=>B.name.toLowerCase().includes(T)||B.description?.toLowerCase().includes(T)||B.extension?.toLowerCase().includes(T)||B.tags?.some(oe=>oe.toLowerCase().includes(T)))}return p.length>0&&(g=g.filter(T=>T.techniques?.some(B=>p.includes(B)))),j.length>0&&(g=g.filter(T=>T.groups?.some(B=>j.includes(B)))),N.length>0&&(g=g.filter(T=>T.software?.some(B=>N.includes(B)))),w.length>0&&(g=g.filter(T=>{const B=new Set([T.extension||"",...T.file_types||[]]);return w.every(oe=>B.has(oe))})),g},[C,E,c,p,j,N,w]),ue=()=>{const g=ie.map(T=>T.recipe_id).filter(T=>!!T);D(g),m(!0)},De=async g=>{try{await $.mutateAsync({name:g.template_name,description:g.template_description,tags:g.tags,recipe_ids:g.payloads}),V.success("Template created successfully"),m(!1)}catch(T){throw V.error("Failed to create template"),T}},ye=g=>{M(g),y(!0)},Ut=async g=>{if(g.recipe_id)try{await Q.delete(g.recipe_id),V.success("Payload deleted successfully"),s.invalidateQueries({queryKey:["payloads"]}),v===g.recipe_id&&u({id:null})}catch{V.error("Failed to delete payload")}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Payloads"}),e.jsx("p",{className:"text-muted-foreground",children:"Browse and manage payload files for your campaigns"})]}),n&&e.jsxs(G,{onClick:()=>o(!0),children:[e.jsx(Rs,{className:"mr-2 h-4 w-4"}),"Add Payload"]})]}),e.jsxs(Ct,{open:!d,onOpenChange:()=>f(),children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(St,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"sm",className:"gap-2",children:d?e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"h-4 w-4"}),"Show Filters"]}):e.jsxs(e.Fragment,{children:[e.jsx(qe,{className:"h-4 w-4"}),"Hide Filters"]})})}),ne&&e.jsx(G,{variant:"secondary",size:"sm",onClick:()=>{u({techniques:null,groups:null,software:null,filetypes:null})},children:"Clear Filters"})]}),e.jsx(Tt,{children:e.jsx(Ks,{activeTab:R,onTabChange:Me,selectedTechniques:p,onTechniqueToggle:Se,selectedGroups:j,onGroupToggle:Te,selectedSoftware:N,onSoftwareToggle:ke,selectedFileTypes:w,onFileTypeToggle:Pe,payloads:C,isLoading:U,metadataCounts:z})})]}),ne&&e.jsx(zs,{selectedTechniques:p,selectedGroups:j,selectedSoftware:N,selectedFileTypes:w,techniques:F,groups:i,softwareList:k,onTechniqueRemove:Se,onGroupRemove:Te,onSoftwareRemove:ke,onFileTypeRemove:Pe}),e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[e.jsx(de,{placeholder:"Search payloads...",value:L,onChange:g=>I(g.target.value),className:"w-64"}),n?e.jsxs(ns,{value:E,onValueChange:g=>Y(g),children:[e.jsx(is,{className:"w-[180px]",children:e.jsx(ls,{placeholder:"Custom payloads"})}),e.jsxs(os,{children:[e.jsx($e,{value:"include",children:"Include Custom"}),e.jsx($e,{value:"only",children:"Only Custom"}),e.jsx($e,{value:"exclude",children:"Exclude Custom"})]})]}):e.jsxs(G,{variant:"outline",className:"w-[180px] justify-between text-muted-foreground",onClick:()=>W(!0),children:["Include Custom",e.jsx(as,{className:"h-3 w-3 text-primary ml-1"})]}),ne&&e.jsxs(G,{variant:"outline",onClick:ue,children:["Create Template from Filtered (",ie.length,")"]})]}),b?e.jsx(lt,{payloadId:v,isExpanded:!0,onCollapse:O,onClose:()=>{u({expanded:null,id:null})}}
187):e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-5 gap-6",children:[e.jsx("div",{className:v?"lg:col-span-3":"lg:col-span-5",children:e.jsx(Ws,{payloads:C,isLoading:U,searchTerm:c,customFilter:E,selectedTechniques:p,selectedGroups:j,selectedSoftware:N,selectedFileTypes:w,selectedPayloadId:v,onPayloadSelect:q,onEditPayload:ye,onDeletePayload:Ut,isInTeam:!!t?.team?.id})}),v&&e.jsx("div",{className:"lg:col-span-2 lg:sticky lg:top-4 lg:self-start",children:e.jsx(lt,{payloadId:v,isExpanded:!1,onExpand:O,onClose:()=>q(null)})})]}),e.jsx(or,{open:h,onOpenChange:o,onSuccess:()=>K()}),e.jsx(cr,{open:_,onOpenChange:y,payload:P,onSuccess:()=>{K(),P?.recipe_id===v&&s.invalidateQueries({queryKey:["payload",v]})}}),e.jsx(ys,{open:x,onOpenChange:m,onSubmit:De,isSubmitting:$.isPending,initialPayloads:S}),e.jsx(rs,{open:A,onOpenChange:W,feature:"custom payloads",requiredTier:"enterprise"})]})}export{Ur as Payloads};

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.