PageSourceSearch

https://www.dangerousgentleman.com/assets/DashboardAdminIntel-2Z5aNdck.js

js dangerousgentleman.com collected 2026-10-05 02:43:52 UTC 79,457 bytes, 41 lines download raw bytes

1import{c as Y,r as a,s as L,j as e,b7 as Sr,aC as B,ba as Fe,F as we,aD as ae,b6 as F,bb as G,aM as Q,b5 as kr,az as lt,bc as ut,aO as Le,aR as oe,bd as mt,b0 as pt,be as $e,aS as X,aT as I,b2 as De,aP as ft,aQ as Mr,aU as Ne,aV as Er,aX as Ir,aY as Dr,aZ as Rr,a_ as Tr,a$ as Ar,bf as xt,aW as Pr,bg as Or,b1 as Fr,b3 as Lr,b4 as $r,d as W,C as Br,aa as Ur,ay as Gr,H as Kr,aJ as Hr,b8 as Ze,bh as qr,bi as ht,aE as gt,aF as bt,aG as vt,aB as Vr}from"./index-1mThbVxv.js";import{D as le,a as ue,b as Be,c as me,d as yt}from"./dialog-DREMG-ts.js";import{T as Je}from"./textarea-DwmeZzya.js";import{S as zr,P as et,H as Yr}from"./switch-DLpHKbkZ.js";import{C as Xr}from"./calendar-C5rbbMm6.js";import{T as jt}from"./triangle-alert-BYmBMySG.js";import{M as Ue}from"./mail-C1HauhHV.js";import{a as Wr,F as Re,C as wt,b as Qr,c as Zr}from"./useIntelBriefs-Da44uCNF.js";import{A as Jr,a as en,b as tn,c as rn,d as nn,e as sn,f as an,g as on}from"./alert-dialog-3QFw0nzW.js";import{C as dn}from"./chevron-right-xxTHvnPJ.js";import{E as tt}from"./eye-DJ5iArCW.js";import{R as cn}from"./refresh-cw-CrKYcEFW.js";import{M as ln}from"./mail-check-BvcU8ToI.js";import{C as un}from"./clock-BCZif5MV.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const mn=Y("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const pn=Y("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/**
12 * @license lucide-react v0.462.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const fn=Y("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/**
17 * @license lucide-react v0.462.0 - ISC
18 *
19 * This source code is licensed under the ISC license.
20 * See the LICENSE file in the root directory of this source tree.
21 */const xn=Y("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
22 * @license lucide-react v0.462.0 - ISC
23 *
24 * This source code is licensed under the ISC license.
25 * See the LICENSE file in the root directory of this source tree.
26 */const hn=Y("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/**
27 * @license lucide-react v0.462.0 - ISC
28 *
29 * This source code is licensed under the ISC license.
30 * See the LICENSE file in the root directory of this source tree.
31 */const rt=Y("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/**
32 * @license lucide-react v0.462.0 - ISC
33 *
34 * This source code is licensed under the ISC license.
35 * See the LICENSE file in the root directory of this source tree.
36 */const gn=Y("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/**
37 * @license lucide-react v0.462.0 - ISC
38 *
39 * This source code is licensed under the ISC license.
40 * See the LICENSE file in the root directory of this source tree.
41 */const bn=Y("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);function Nt({open:t,briefId:r,onClose:s}
41){const[n,o]=a.useState(!1),[i,f]=a.useState(""),[p,x]=a.useState(""),[b,m]=a.useState(""),[u,c]=a.useState(null),[g,j]=a.useState("desktop"),[C,w]=a.useState("light"),[v,P]=a.useState(!1);return a.useEffect(()=>{!t||!r||(o(!0),c(null),L.functions.invoke("preview-intel-brief",{body:{brief_id:r,is_test:v}}).then(({data:N,error:k})=>{if(k){c(k.message??"Preview failed");return}f((N==null?void 0:N.html)??""),x((N==null?void 0:N.subject)??""),m((N==null?void 0:N.briefUrl)??"")}).catch(N=>c(N instanceof Error?N.message:String(N))).finally(()=>o(!1)))},[t,r,v]),e.jsx(le,{open:t,onOpenChange:N=>!N&&s(),children:e.jsxs(ue,{className:"max-w-4xl rounded-none bg-background border-border p-0 overflow-hidden",children:[e.jsxs(Be,{className:"px-5 pt-5 pb-3 border-b border-border",children:[e.jsx(me,{className:"font-heading-bold text-[16px] tracking-[0.04em]",children:"Email Preview"}),e.jsxs("div",{className:"font-body text-[12px] text-muted-foreground line-clamp-1",children:["Subject: ",e.jsx("span",{className:"text-foreground",children:p||", "})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-5 py-2 border-b border-border bg-muted/20",children:[e.jsx(ve,{active:g==="desktop",onClick:()=>j("desktop"),icon:e.jsx(fn,{className:"h-3.5 w-3.5"}),children:"Desktop"}),e.jsx(ve,{active:g==="mobile",onClick:()=>j("mobile"),icon:e.jsx(hn,{className:"h-3.5 w-3.5"}),children:"Mobile"}),e.jsx("span",{className:"mx-2 h-4 w-px bg-border"}),e.jsx(ve,{active:C==="light",onClick:()=>w("light"),icon:e.jsx(gn,{className:"h-3.5 w-3.5"}),children:"Light"}),e.jsx(ve,{active:C==="dark",onClick:()=>w("dark"),icon:e.jsx(xn,{className:"h-3.5 w-3.5"}),children:"Dark client"}),e.jsx("span",{className:"mx-2 h-4 w-px bg-border"}),e.jsxs("label",{className:"inline-flex items-center gap-2 text-[11px] font-heading-bold tracking-[0.12em] uppercase text-muted-foreground cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:v,onChange:N=>P(N.target.checked),className:"h-3.5 w-3.5"}),"Show as TEST"]}),e.jsx("div",{className:"ml-auto",children:b&&e.jsxs("a",{href:b,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[11px] font-heading-bold tracking-[0.12em] uppercase text-muted-foreground hover:text-foreground",children:["Open CTA ",e.jsx(Sr,{className:"h-3 w-3"})]})})]}),e.jsx("div",{className:"p-4 max-h-[70vh] overflow-auto",style:{backgroundColor:C==="dark"?"#0a0a0a":"#f5f5f5"},children:n?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(B,{className:"h-5 w-5 animate-spin text-primary"})}):u?e.jsx("div",{className:"text-destructive font-body text-sm p-4 bg-destructive/5 border border-destructive/30",children:u}):e.jsx("div",{className:"mx-auto",style:{width:g==="mobile"?375:640,maxWidth:"100%"},children:e.jsx("iframe",{title:"Email preview",srcDoc:i,sandbox:"",className:"w-full bg-white",style:{height:"60vh",border:"1px solid #e5e5e5"}})})}),e.jsx("div",{className:"px-5 py-3 border-t border-border text-[11px] font-body text-muted-foreground",children:"This is a render preview. No email is sent."})]})})}function ve({active:t,onClick:r,icon:s,children:n}){return e.jsxs("button",{type:"button",onClick:r,className:`inline-flex items-center gap-1.5 px-2.5 py-1 border font-heading-bold text-[10px] tracking-[0.15em] uppercase transition-colors ${t?"border-primary/60 bg-primary/10 text-primary":"border-border bg-background text-muted-foreground hover:text-foreground"}`,children:[s,n]})}const nt=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function _t({open:t,briefId:r,onClose:s}){const[n,o]=a.useState([]),[i,f]=a.useState(""),[p,x]=a.useState(!1);a.useEffect(()=>{t&&(f(""),L.auth.getUser().then(({data:c})=>{var j;const g=(j=c.user)==null?void 0:j.email;o(g?[g]:[])}))},[t]);const b=c=>{const g=c.split(/[,\s;]+/).map(C=>C.trim().toLowerCase()).filter(Boolean);let j=[...n];for(const C of g)if(nt.test(C)&&!j.includes(C)){if(j.length>=5)break;j.push(C)}o(j)},m=c=>o(g=>g.filter(j=>j!==c)),u=async()=>{if(!r)return;i.trim()&&b(i);const c=(()=>{const g=[...n];if(i.trim())for(const j of i.split(/[,\s;]+/).map(C=>C.trim().toLowerCase()))nt.test(j)&&!g.includes(j)&&g.length<5&&g.push(j);return g})();if(c.length===0){F({title:"Add at least one valid email",variant:"destructive"});return}x(!0);try{const{data:g,error:j}=await L.functions.invoke("notify-intel-brief",{body:{brief_id:r,mode:"test",recipients:c}});if(j)throw j;const C=((g==null?void 0:g.results)??[]).filter(w=>!w.ok);C.length===0?(F({title:"Test email queued",description:`Sent to ${c.length} recipient${c.length>
411?"s":""}.`}),s()):F({title:`Sent ${c.length-C.length}/${c.length}`,description:C.map(w=>`${w.email}: ${w.error}`).join(" · "),variant:"destructive"})}catch(g){F({title:"Test send failed",description:g instanceof Error?g.message:String(g),variant:"destructive"})}finally{x(!1)}};return e.jsx(le,{open:t,onOpenChange:c=>!c&&s(),children:e.jsxs(ue,{className:"max-w-lg rounded-none bg-background border-border",children:[e.jsxs(Be,{children:[e.jsx(me,{className:"font-heading-bold tracking-[0.04em]",children:"Send Test Email"}),e.jsxs(yt,{className:"font-body text-[13px] text-muted-foreground",children:["Test emails are clearly labeled ",e.jsx("span",{className:"font-heading-bold",children:"[TEST]"})," and do not affect production send counts or notify members."]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"border border-border bg-background p-2 min-h-[44px] flex flex-wrap gap-1.5 items-center",children:[n.map(c=>e.jsxs("span",{className:"inline-flex items-center gap-1 bg-muted px-2 py-0.5 font-body text-[12px] text-foreground",children:[c,e.jsx("button",{onClick:()=>m(c),className:"hover:text-destructive","aria-label":`Remove ${c}`,children:e.jsx(Fe,{className:"h-3 w-3"})})]},c)),e.jsx("input",{value:i,onChange:c=>f(c.target.value),onKeyDown:c=>{(c.key==="Enter"||c.key===",")&&(c.preventDefault(),i.trim()&&(b(i),f("")))},onBlur:()=>{i.trim()&&(b(i),f(""))},placeholder:n.length>=5?"Max 5 recipients":"Add email…",disabled:n.length>=5,className:"flex-1 min-w-[140px] bg-transparent text-[13px] font-body outline-none disabled:opacity-50"})]}),e.jsx("p",{className:"text-[11px] font-body text-muted-foreground",children:"Up to 5 recipients. Press Enter or comma to add."})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 pt-3 border-t border-border",children:[e.jsx("button",{onClick:s,className:"px-4 py-2 font-heading-bold text-[12px] tracking-[0.15em] text-muted-foreground hover:text-foreground",children:"CANCEL"}),e.jsxs(we,{as:"button",onClick:u,disabled:p,className:"text-primary-foreground",outerClassName:"bg-primary",innerClassName:"bg-primary group-hover:bg-primary/90",contentClassName:"px-5 py-2.5 font-heading-bold text-[12px] tracking-[0.15em] inline-flex items-center gap-2",children:[p?e.jsx(B,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ae,{className:"h-3.5 w-3.5"}),"SEND TEST"]})]})]})})}function Ee(t){if(!t)return"";const r=new Date(t);if(Number.isNaN(r.getTime()))return"";const s=n=>String(n).padStart(2,"0");return`${r.getFullYear()}-${s(r.getMonth()+1)}-${s(r.getDate())}T${s(r.getHours())}:${s(r.getMinutes())}`}function vn(t){if(!t)return"";const r=new Date(/^\d{4}-\d{2}-\d{2}$/.test(t)?`${t}T12:00:00Z`:t);return Number.isNaN(r.getTime())?"":r.toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"UTC"})}function Ct({open:t,brief:r,onClose:s,onSent:n}){const[o,i]=a.useState(null),[f,p]=a.useState(""),[x,b]=a.useState(!1),[m,u]=a.useState("now"),[c,g]=a.useState(""),[j,C]=a.useState(null),w=a.useRef(!1),v=j??r,P=(v==null?void 0:v.issue_number)??(v==null?void 0:v.extracted_issue_number)??null,N=(v==null?void 0:v.publish_date)??(v==null?void 0:v.extracted_publish_date)??null,k=((v==null?void 0:v.notification_send_count)??0)>0,M=P!=null?String(P):"",h=(v==null?void 0:v.scheduled_send_at)??null;a.useEffect(()=>{if(!t||!r)return;p(""),i(null),C(null),u(r.scheduled_send_at&&(r.notification_send_count??0)===0?"schedule":"now"),g(Ee(r.scheduled_send_at));let d=!1;return L.from("intel_briefs").select("*").eq("id",r.id).maybeSingle().then(({data:D})=>{if(d||!D)return;const E=D;C(E),u(E.scheduled_send_at&&(E.notification_send_count??0)===0?"schedule":"now"),g(Ee(E.scheduled_send_at))}),L.rpc("intel_active_brotherhood_count").then(({data:D})=>{!d&&typeof D=="number"&&i(D)}),()=>{d=!0}},[t,r==null?void 0:r.id]);const l=!k||f.trim()===M&&M!=="",y=c?new Date(c):null,T=!!y&&!Number.isNaN(y.getTime())&&y.getTime()>Date.now(),A=Ee(new Date(Date.now()+6e4).toISOString()),R=async()=>{if(!(!r||!l)&&!w.current){w.current=!0,b(!0);try{h&&await L.from("intel_briefs").update({scheduled_send_at:null}).eq("id",r.id);const{data:d,error:D}=await L.functions.invoke("notify-intel-brief",{body:{brief_id:r.id,mode:"production",force:k}});if(D)throw D;const E=typeof(d==null?void 0:d.enqueued)=="number"?d.enqueued:null,be=typeof(d==null?void 0:d.failed)=="number"?d.failed:0;F({title:k?"Notification requeued":"Notification queued",description:(E==null?"Email queued for Brotherhood members.":`Email queued for ${E} Brotherhood member${E===1?"":"s"}.`)+(be>0?` ${be} skipped or failed.`:"")}
41),n==null||n(),s()}catch(d){F({title:"Send failed",description:d instanceof Error?d.message:String(d),variant:"destructive"})}finally{w.current=!1,b(!1)}}},S=async()=>{if(!(!r||!y||!T)&&!w.current){w.current=!0,b(!0);try{const{error:d}=await L.from("intel_briefs").update({scheduled_send_at:y.toISOString()}).eq("id",r.id);if(d)throw d;F({title:"Send scheduled",description:`Members will be notified on ${y.toLocaleString()}.`}),n==null||n(),s()}catch(d){F({title:"Could not schedule",description:d instanceof Error?d.message:String(d),variant:"destructive"})}finally{w.current=!1,b(!1)}}},O=async()=>{if(r&&!w.current){w.current=!0,b(!0);try{const{error:d}=await L.from("intel_briefs").update({scheduled_send_at:null}).eq("id",r.id);if(d)throw d;F({title:"Scheduled send cancelled"}),n==null||n(),s()}catch(d){F({title:"Could not cancel",description:d instanceof Error?d.message:String(d),variant:"destructive"})}finally{w.current=!1,b(!1)}}};return r?e.jsx(le,{open:t,onOpenChange:d=>!d&&!x&&s(),children:e.jsxs(ue,{className:"max-w-lg rounded-none bg-background border-border",children:[e.jsxs(Be,{children:[e.jsx(me,{className:"font-heading-bold tracking-[0.04em] text-[18px]",children:m==="schedule"?"Schedule notification":`Send notification to ${o??"…"} active Brotherhood members?`}),e.jsx(yt,{className:"font-body text-[13px] text-muted-foreground",children:m==="schedule"?"Pick a date and time. The system will email every active Brotherhood member automatically.":"This will email every active Brotherhood member with a link to read the briefing."})]}),e.jsxs("div",{className:"space-y-3 border border-border bg-muted/20 p-4",children:[e.jsx(re,{label:"Issue",value:M?`#${M}`:"Not assigned"}),e.jsx(re,{label:"Title",value:(v==null?void 0:v.title)??(v==null?void 0:v.extracted_title)??"Untitled"}),e.jsx(re,{label:"Publish date",value:vn(N)||"Not set"}),e.jsx(re,{label:"Estimated recipients",value:o==null?"Loading…":String(o)}),k&&e.jsx(re,{label:"Last sent",value:`${v==null?void 0:v.notification_send_count}× · ${v!=null&&v.notification_sent_at?new Date(v.notification_sent_at).toLocaleString():"date unknown"}`}),h&&e.jsx(re,{label:"Currently scheduled",value:new Date(h).toLocaleString()})]}),!k&&e.jsxs("div",{className:"flex border border-border bg-card",children:[e.jsx("button",{type:"button",onClick:()=>u("now"),disabled:x,className:`flex-1 px-3 py-2 font-heading-bold text-[11px] tracking-[0.15em] uppercase transition-colors disabled:opacity-50 ${m==="now"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:"Send now"}),e.jsxs("button",{type:"button",onClick:()=>u("schedule"),disabled:x,className:`flex-1 px-3 py-2 font-heading-bold text-[11px] tracking-[0.15em] uppercase transition-colors inline-flex items-center justify-center gap-1.5 disabled:opacity-50 ${m==="schedule"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Xr,{className:"h-3.5 w-3.5"})," Schedule"]})]}),m==="schedule"&&e.jsxs("div",{className:"space-y-2 border border-border bg-muted/10 p-3",children:[e.jsx("label",{className:"font-heading-bold text-[10px] tracking-[0.15em] uppercase text-muted-foreground",children:"Send at (your local time)"}),e.jsx("input",{type:"datetime-local",value:c,min:A,disabled:x,onChange:d=>g(d.target.value),className:"w-full h-10 px-3 rounded-none bg-background border border-border font-body text-[13px] disabled:opacity-50"}),c&&!T&&e.jsx("p",{className:"font-body text-[11px] text-destructive",children:"Choose a time in the future."})]}),k&&e.jsxs("div",{className:"space-y-2 border border-destructive/30 bg-destructive/5 p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 font-heading-bold text-[11px] tracking-[0.15em] uppercase text-destructive",children:[e.jsx(jt,{className:"h-3.5 w-3.5"})," Resend confirmation"]}),e.jsxs("p",{className:"font-body text-[12px] text-muted-foreground",children:["This brief was already sent. Type the issue number"," ",e.jsx("span",{className:"font-heading-bold text-foreground",children:M||"?"})," to confirm a resend."]}),e.jsx("input",{value:f,onChange:d=>p(d.target.value),placeholder:M,disabled:x,className:"w-full h-10 px-3 rounded-none bg-background border border-border font-body text-[13px] disabled:opacity-50"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 pt-3 border-t border-border",children:[e.jsx("div",{children:h&&e.jsx("button",{onClick:O,disabled:x,className:"px-3 py-2 font-heading-bold text-[11px] tracking-[0.15em] text-destructive hover:text-destructive/80 disabled:opacity-50",children:"CANCEL SCHEDULE"})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:s,disabled:x,className:"px-4 py-2 font-heading-bold text-[12px] tracking-[0.15em] text-muted-foreground hover:text-foreground disabled:opacity-50",children:"CLOSE"}),e.jsxs(we,{as:"button",onClick:m==="schedule"?S:R,disabled:x||(m==="now"?!l:!T),className:"text-primary-foreground disabled:opacity-50",outerClassName:"bg-primary",innerClassName:"bg-primary group-hover:bg-primary/90",contentClassName:"px-5 py-2.5 font-heading-bold text-[12px] tracking-[0.15em] inline-flex items-center gap-2",children:[x&&e.jsx(B,{className:"h-3.5 w-3.5 animate-spin"}),x?m==="schedule"?"SCHEDULING…":"QUEUEING…":m==="schedule"?h?"UPDATE SCHEDULE":"SCHEDULE SEND":k?"RESEND TO ALL MEMBERS":"SEND TO ALL MEMBERS"]})]})]})]})}):null}function re({label:t,value:r}){return e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsx("div",{className:"font-heading-bold text-[10px] tracking-[0.15em] uppercase text-muted-foreground shrink-0",children:t}),e.jsx("div",{className:"font-body text-[13px] text-foreground text-right line-clamp-2",children:r})]})}function yn(t){var r;return{series_name:t.series_name??t.extracted_series_name??"Strength Through Awareness",title:t.title??t.extracted_title??"",issue_number:String(t.issue_number??t.extracted_issue_number??""),publish_date:t.publish_date??t.extracted_publish_date??"",author_name:t.author_name??t.extracted_author_name??"",excerpt:t.excerpt??t.extracted_excerpt??"",summary:t.summary??t.extracted_summary??"",tags:(r=t.tags)!=null&&r.length?t.tags:t.extracted_tags??[],read_time_minutes:String(t.read_time_minutes??t.extracted_read_time_minutes??""),featured_image_url:t.featured_image_url??"",visibility:t.visibility??"brotherhood",ai_indexed:t.ai_indexed??!1}}function z(t,r){return t!=null&&t!==""?!1:r!=null&&r!==""}function jn({brief:t,onClose:r,onSaved:s}){var S,O;
41const[n,o]=a.useState(yn(t)),[i,f]=a.useState(""),[p,x]=a.useState(!1),[b,m]=a.useState(!1),[u,c]=a.useState(!1),[g,j]=a.useState(!1),[C,w]=a.useState(!1),[v,P]=a.useState(!1),[N,k]=a.useState((t.notification_send_count??0)===0),M=(d,D)=>o(E=>({...E,[d]:D})),h=d=>{const D=d.trim();D&&(n.tags.includes(D)||n.tags.length>=8||M("tags",[...n.tags,D]))},l=d=>{const D=n.issue_number?parseInt(n.issue_number,10):null,E=n.read_time_minutes?parseInt(n.read_time_minutes,10):null;return{series_name:n.series_name.trim()||"Strength Through Awareness",title:n.title.trim()||null,issue_number:Number.isFinite(D)?D:null,publish_date:n.publish_date||null,author_name:n.author_name.trim()||null,excerpt:n.excerpt.trim()||null,summary:n.summary.trim()||null,tags:n.tags,read_time_minutes:Number.isFinite(E)?E:null,featured_image_url:n.featured_image_url.trim()||null,visibility:n.visibility||"brotherhood",ai_indexed:n.ai_indexed,is_published:d}},y=()=>n.title.trim()?!n.issue_number||!Number.isFinite(parseInt(n.issue_number,10))?"Issue number is required.":n.publish_date?null:"Publish date is required.":"Title is required to publish.",T=async d=>{if(d){const E=y();if(E){F({title:"Missing fields",description:E,variant:"destructive"});return}}d?m(!0):x(!0);const D=!t.is_published;try{const{error:E}=await L.from("intel_briefs").update(l(d)).eq("id",t.id);if(E)throw E;F({title:d?"Brief published":"Draft saved",description:d?"Members can now read this briefing.":void 0}),d&&D&&N&&(t.notification_send_count??0)===0?P(!0):s()}catch(E){F({title:"Save failed",description:E instanceof Error?E.message:"Try again.",variant:"destructive"})}finally{m(!1),x(!1)}},A=async()=>{c(!0);try{const{error:d}=await L.functions.invoke("intel-extract-metadata",{body:{brief_id:t.id}});if(d)throw d;F({title:"Re-extraction started",description:"Refresh in a moment."}),s()}catch(d){F({title:"Re-extraction failed",description:d instanceof Error?d.message:"Try again.",variant:"destructive"})}finally{c(!1)}},R=()=>e.jsxs(kr,{variant:"outline",className:"ml-2 border-primary/40 bg-primary/5 px-1.5 py-0 font-heading-bold text-[9px] tracking-[0.15em] text-primary uppercase rounded-none",children:[e.jsx(rt,{className:"h-2.5 w-2.5 mr-1"})," AI"]});return e.jsxs("div",{className:"space-y-5",children:[t.extraction_status==="failed"&&e.jsxs("div",{className:"border border-destructive/40 bg-destructive/5 p-3 text-[13px] text-destructive font-body",children:["AI extraction failed: ",t.extraction_error??"unknown error",". Fill the form manually below."]}),e.jsxs("div",{children:[e.jsxs(G,{className:"font-heading-bold text-[11px] tracking-[0.15em] uppercase text-muted-foreground",children:["Series / Masthead ",z(t.series_name,t.extracted_series_name)&&e.jsx(R,{})]}),e.jsx(Q,{value:n.series_name,onChange:d=>M("series_name",d.target.value),className:"mt-1 rounded-none bg-background border-border",placeholder:"Strength Through Awareness"}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground font-body",children:'Recurring publication label shown above the unique issue title (e.g. "Strength Through Awareness").'})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs(G,{className:"font-heading-bold text-[11px] tracking-[0.15em] uppercase text-muted-foreground",children:["Issue Title ",z(t.title,t.extracted_title)&&e.jsx(R,{})]}),e.jsx(Q,{value:n.title,onChange:d=>M("title",d.target.value),className:"mt-1 rounded-none bg-background border-border",placeholder:"Domestic Escalation Indicators"}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground font-body",children:"Unique headline for THIS issue. Do not put the masthead here."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsxs(G,{className:"font-heading-bold text-[11px] tracking-[0.15em] uppercase text-muted-foreground",children:["Issue # ",z(t.issue_number,t.extracted_issue_number)&&e.jsx(R,{})]}),e.jsx(Q,{type:"number",value:n.issue_number,onChange:d=>M("issue_number",d.target.value),className:"mt-1 rounded-none bg-background border-border",placeholder:"8"})]}),e.jsxs("div",{children:[e.jsxs(G,{className:"font-heading-bold text-[11px] tracking-[0.15em] uppercase text-muted-foreground",children:["Publish Date ",z(t.publish_date,t.extracted_publish_date)&&e.jsx(R,{})]}),e.jsx(Q,{type:"date",value:n.publish_date,onChange:d=>M("publish_date",d.target.value),className:"mt-1 rounded-none bg-background border-border"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs(G,{className:"font-heading-bold text-[11px] tracking-[0.15em] uppercase text-muted-foreground",children:["Author ",z(t.author_name,t.extracted_author_name)&&e.jsx(R,{})]}),e.jsx(Q,{value:n.author_name,onChange:d=>M("author_name",d.target.value),className:"mt-1 rounded-none bg-background border-border",placeholder:"Optional"})]}),e.jsxs("div",{children:[e.jsxs(G,{className:"font-heading-bold text-[11px] tracking-[0.15em] uppercase text-muted-foreground",children:["Read Time (min) ",z(t.read_time_minutes,t.extracted_read_time_minutes)&&e.jsx(R,{})]}),e.jsx(Q,{type:"number",value:n.read_time_minutes,onChange:d=>M("read_time_minutes",d.target.value),className:"mt-1 rounded-none bg-background border-border",placeholder:"6"})]})]}),e.jsxs("div",{children:[e.jsxs(G,{className:"font-heading-bold text-[11px] tracking-[0.15em] uppercase text-muted-foreground",children:["Excerpt (card preview) ",z(t.excerpt,t.extracted_excerpt)&&e.jsx(R,{})]}),e.jsx(Je,{value:n.excerpt,onChange:d=>M("excerpt",d.target.value),rows:2,className:"mt-1 rounded-none bg-background border-border font-body",placeholder:"Short 1-2 sentence preview shown on briefing cards."})]}),e.jsxs("div",{children:[e.jsxs(G,{className:"font-heading-bold text-[11px] tracking-[0.15em] uppercase text-muted-foreground",children:["Summary ",z(t.summary,t.extracted_summary)&&e.jsx(R,{})]}),e.jsx(Je,{value:n.summary,onChange:d=>M("summary",d.target.value),rows:4,className:"mt-1 rounded-none bg-background border-border font-body"})]}),e.jsxs("div",{children:[e.jsxs(G,{className:"font-heading-bold text-[11px] tracking-[0.15em] uppercase text-muted-foreground",children:["Tags ",((S=t.tags)==null?void 0:S.length)===0&&(((O=t.extracted_tags)==null?void 0:O.length)??0)>0&&e.jsx(R,{})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5 border border-border bg-background p-2 min-h-[42px]",children:[n.tags.map(d=>e.jsxs("span",{className:"inline-flex items-center gap-1 bg-muted px-2 py-0.5 font-heading-bold text-[10px] tracking-[0.12em] uppercase text-muted-foreground",children:[d,e.jsx("button",{onClick:()=>M("tags",n.tags.filter(D=>
41D!==d)),className:"hover:text-destructive","aria-label":`Remove ${d}`,children:e.jsx(Fe,{className:"h-3 w-3"})})]},d)),e.jsx("input",{value:i,onChange:d=>f(d.target.value),onKeyDown:d=>{d.key==="Enter"||d.key===","?(d.preventDefault(),h(i),f("")):d.key==="Backspace"&&!i&&n.tags.length&&M("tags",n.tags.slice(0,-1))},onBlur:()=>{i.trim()&&(h(i),f(""))},placeholder:n.tags.length?"":"Add tags…",className:"flex-1 min-w-[120px] bg-transparent text-[12px] outline-none font-body"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(G,{className:"font-heading-bold text-[11px] tracking-[0.15em] uppercase text-muted-foreground",children:"Featured Image URL (optional)"}),e.jsx(Q,{value:n.featured_image_url,onChange:d=>M("featured_image_url",d.target.value),className:"mt-1 rounded-none bg-background border-border",placeholder:"https://…"})]}),e.jsxs("div",{children:[e.jsx(G,{className:"font-heading-bold text-[11px] tracking-[0.15em] uppercase text-muted-foreground",children:"Visibility"}),e.jsx("select",{value:n.visibility,onChange:d=>M("visibility",d.target.value),className:"mt-1 w-full h-10 px-3 rounded-none bg-background border border-border font-body text-[14px]",children:e.jsx("option",{value:"brotherhood",children:"Brotherhood Members"})})]})]}),e.jsxs("div",{className:"flex items-center justify-between border-t border-border pt-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(zr,{id:"ai-indexed",checked:n.ai_indexed,onCheckedChange:d=>M("ai_indexed",d)}),e.jsx(G,{htmlFor:"ai-indexed",className:"font-heading-bold text-[11px] tracking-[0.15em] uppercase text-muted-foreground",children:"AI Indexed"})]}),e.jsxs("button",{onClick:A,disabled:u,className:"inline-flex items-center gap-2 text-[11px] font-heading-bold tracking-[0.15em] text-muted-foreground hover:text-foreground transition-colors uppercase",children:[u?e.jsx(B,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(rt,{className:"h-3.5 w-3.5"}),"Re-extract with AI"]})]}),e.jsxs("div",{className:"border-t border-border pt-4 space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-heading-bold text-[10px] tracking-[0.15em] uppercase text-muted-foreground mr-2",children:"Email QA:"}),e.jsxs("button",{type:"button",onClick:()=>j(!0),className:"inline-flex items-center gap-1.5 border border-border bg-background px-3 py-1.5 font-heading-bold text-[11px] tracking-[0.15em] uppercase text-foreground hover:bg-muted",children:[e.jsx(Ue,{className:"h-3.5 w-3.5"})," Preview Email"]}),e.jsxs("button",{type:"button",onClick:()=>w(!0),className:"inline-flex items-center gap-1.5 border border-border bg-background px-3 py-1.5 font-heading-bold text-[11px] tracking-[0.15em] uppercase text-foreground hover:bg-muted",children:[e.jsx(ae,{className:"h-3.5 w-3.5"})," Send Test"]}),t.is_published&&e.jsxs("button",{type:"button",onClick:()=>P(!0),className:"inline-flex items-center gap-1.5 border border-primary/40 bg-primary/5 px-3 py-1.5 font-heading-bold text-[11px] tracking-[0.15em] uppercase text-primary hover:bg-primary/10",children:[e.jsx(ae,{className:"h-3.5 w-3.5"}),(t.notification_send_count??0)>0?"Resend Notification":"Send Notification"]}),(t.notification_send_count??0)>0&&e.jsxs("span",{className:"ml-1 inline-flex items-center gap-1 px-2 py-0.5 border border-border bg-muted/40 font-heading-bold text-[10px] tracking-[0.12em] uppercase text-muted-foreground",children:["Notified ",t.n
41otification_send_count,"× ·"," ",t.notification_sent_at?new Date(t.notification_sent_at).toLocaleDateString():""]})]}),!t.is_published&&(t.notification_send_count??0)===0&&e.jsxs("label",{className:"flex items-center gap-2 text-[12px] font-body text-foreground cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:N,onChange:d=>k(d.target.checked),className:"h-4 w-4"}),"Notify Brotherhood members by email when publishing (you'll confirm in the next step)"]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-3",children:[e.jsx("button",{onClick:r,className:"px-4 py-2 font-heading-bold text-[12px] tracking-[0.15em] text-muted-foreground hover:text-foreground",children:"CANCEL"}),e.jsxs("button",{onClick:()=>T(!1),disabled:p||b,className:"inline-flex items-center gap-2 border border-border bg-card px-4 py-2 font-heading-bold text-[12px] tracking-[0.15em] text-foreground hover:bg-muted disabled:opacity-50",children:[p&&e.jsx(B,{className:"h-3.5 w-3.5 animate-spin"}),"SAVE DRAFT"]}),e.jsxs(we,{as:"button",onClick:()=>T(!0),disabled:b||p,className:"text-primary-foreground disabled:opacity-50",outerClassName:"bg-primary",innerClassName:"bg-primary group-hover:bg-primary/90",contentClassName:"px-5 py-2.5 font-heading-bold text-[12px] tracking-[0.15em]",children:[b&&e.jsx(B,{className:"h-3.5 w-3.5 animate-spin"}),"PUBLISH BRIEF"]})]})]}),e.jsx(Nt,{open:g,briefId:t.id,onClose:()=>j(!1)}),e.jsx(_t,{open:C,briefId:t.id,onClose:()=>w(!1)}),e.jsx(Ct,{open:v,brief:t,onClose:()=>P(!1),onSent:s})]})}async function wn(t){const r=await t.arrayBuffer(),s=await crypto.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(s)).map(n=>n.toString(16).padStart(2,"0")).join("")}function Nn({open:t,onClose:r,onSaved:s,editingBriefId:n}){const[o,i]=a.useState(n??null),{data:f}=Wr(o),[p,x]=a.useState([]),[b,m]=a.useState(!1),u=a.useRef(!1);if(a.useEffect(()=>{t&&(i(n??null),x([]))},[t,n]),n)return e.jsx(le,{open:t,onOpenChange:h=>!h&&r(),children:e.jsxs(ue,{className:"max-w-3xl w-[95vw] max-h-[92vh] overflow-y-auto bg-background border-border rounded-none p-0",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-border bg-card",children:[e.jsx(me,{className:"font-heading-bold text-[18px] tracking-[0.04em] text-foreground",children:"Edit Intelligence Brief"}),e.jsx("p",{className:"mt-1 font-body text-[12px] text-muted-foreground",children:"Review the AI suggestions, edit any field, then publish."})]}),e.jsx("div",{className:"p-6",children:f?e.jsx(jn,{brief:f,onClose:r,onSaved:s}):e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(B,{className:"h-6 w-6 text-primary animate-spin"})})})]})});const c=(h,l)=>{x(y=>y.map(T=>T.id===h?{...T,...l}:T))},g=async h=>{const l=h.filter(S=>S.type==="application/pdf"||S.name.toLowerCase().endsWith(".pdf")),y=l.filter(S=>S.size>25*1024*1024),T=l.filter(S=>S.size<=25*1024*1024);if(h.length!==l.length&&F({title:"Some files skipped",description:"Only PDF files are accepted.",variant:"destructive"}),y.length&&F({title:"Some files too large",description:`${y.length} file(s) exceed 25MB and were skipped.`,variant:"destructive"}),!T.length)return;const A=new Set,R=[];for(const S of T){const O=`${S.name}::${S.size}`;A.has(O)||(A.add(O),!p.some(d=>d.file.name===S.name&&d.file.size===S.size)&&R.push({id:crypto.randomUUID(),file:S,status:"hashing"}))}if(R.length){x(S=>[...S,...R]);for(const S of R)try{const O=await wn(S.file),{data:d}=await L.from("intel_briefs").select("id, pdf_filename, pdf_sha256").or(`pdf_sha256.eq.${O},pdf_filename.eq.${S.file.name}`).limit(1),D=d==null?void 0:d[0];D?c(S.id,{sha256:O,status:"duplicate",duplicateOf:{id:D.id,filename:D.pdf_filename,reason:D.pdf_sha256===O?"hash":"filename"}}):c(S.id,{sha256:O,status:"queued"})}catch(O){c(S.id,{status:"failed",error:O instanceof Error?O.message:"Hash failed"})}}},j=async h=>{var l;c(h.id,{status:"uploading"});try{const{data:{session:y}}=await L.auth.getSession(),T=(l=y==null?void 0:y.user)==null?void 0:l.id,{data:A,error:R}=await L.from("intel_briefs").insert({pdf_path:"pending",pdf_filename:h.file.name,pdf_sha256:h.sha256??null,extraction_status:"pending",is_published:!1,created_by:T}).select("id").single();if(R||!A)throw R??new Error("Failed to create draft");
41const S=`briefs/${A.id}/${h.file.name}`,{error:O}=await L.storage.from("intel-briefs").upload(S,h.file,{contentType:"application/pdf",upsert:!1});if(O)throw O;const{error:d}=await L.from("intel_briefs").update({pdf_path:S}).eq("id",A.id);if(d)throw d;L.functions.invoke("intel-extract-metadata",{body:{brief_id:A.id}}),c(h.id,{status:"uploaded",briefId:A.id})}catch(y){c(h.id,{status:"failed",error:y instanceof Error?y.message:"Upload failed"})}},C=async()=>{if(!u.current){u.current=!0;try{const h=p.filter(y=>y.status==="queued"||y.status==="duplicate"&&y.forceUpload);for(const y of h)await j(y);const l=p.some(y=>y.status==="failed");s(),l||F({title:"Uploads complete",description:`${h.length} brief(s) uploaded. AI extraction running in background.`})}finally{u.current=!1}}},w=h=>x(l=>l.filter(y=>y.id!==h)),v=p.filter(h=>h.status==="queued"||h.status==="duplicate"&&h.forceUpload).length,P=p.filter(h=>h.status==="hashing").length,N=p.filter(h=>h.status==="duplicate"&&!h.forceUpload).length,k=p.some(h=>h.status==="uploading"),M=p.length>0&&p.every(h=>["uploaded","failed","duplicate"].includes(h.status)&&!(h.status==="duplicate"&&h.forceUpload));return e.jsx(le,{open:t,onOpenChange:h=>!h&&r(),children:e.jsxs(ue,{className:"max-w-3xl w-[95vw] max-h-[92vh] overflow-y-auto bg-background border-border rounded-none p-0",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-border bg-card",children:[e.jsx(me,{className:"font-heading-bold text-[18px] tracking-[0.04em] text-foreground",children:"New Intelligence Briefs"}),e.jsx("p",{className:"mt-1 font-body text-[12px] text-muted-foreground",children:"Drop one or more PDFs, duplicates are detected automatically. AI extracts metadata after upload."})]}),e.jsxs("div",{className:"p-6 space-y-5",children:[e.jsxs("label",{onDragOver:h=>{h.preventDefault(),m(!0)},onDragLeave:()=>m(!1),onDrop:h=>{h.preventDefault(),m(!1);const l=Array.from(h.dataTransfer.files??[]);l.length&&g(l)},className:`flex flex-col items-center justify-center gap-2 border-2 border-dashed p-8 text-center cursor-pointer transition-colors ${b?"border-primary bg-primary/5":"border-border bg-card hover:border-primary/40"}`,children:[e.jsx("input",{type:"file",accept:"application/pdf.pdf",multiple:!0,className:"hidden",disabled:k,onChange:h=>{const l=Array.from(h.target.files??[]);l.length&&g(l),h.currentTarget.value=""}}),e.jsx(bn,{className:"h-7 w-7 text-muted-foreground"}),e.jsx("div",{className:"font-heading-bold text-[13px] tracking-[0.04em] text-foreground",children:"DROP PDFs OR CLICK TO BROWSE"}),e.jsx("div",{className:"font-body text-[11px] text-muted-foreground",children:"Multi-select supported · PDF only · max 25MB each"})]}),p.length>0&&e.jsxs("div",{className:"border border-border bg-card",children:[e.jsxs("div",{className:"px-4 py-2.5 border-b border-border flex items-center justify-between",children:[e.jsxs("span",{className:"font-heading-bold text-[11px] tracking-[0.15em] uppercase text-muted-foreground",children:["Upload Queue (",p.length,")"]}),e.jsxs("span",{className:"font-body text-[11px] text-muted-foreground",children:[P>0&&`${P} scanning · `,N>0&&`${N} duplicates · `,v>0&&`${v} ready`]})]}),e.jsx("ul",{className:"divide-y divide-border",children:p.map(h=>e.jsx(_n,{item:h,onRemove:()=>w(h.id),onForce:()=>c(h.id,{forceUpload:!0,status:"queued"})},h.id))})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3",children:[e.jsx("button",{onClick:r,className:"px-4 py-2 font-heading-bold text-[11px] tracking-[0.15em] uppercase text-muted-foreground hover:text-foreground transition-colors",children:M?"Close":"Cancel"}),e.jsxs("button",{onClick:C,disabled:v===0||k||P>0,className:"inline-flex items-center gap-2 px-5 py-2.5 bg-primary text-primary-foreground font-heading-bold text-[12px] tracking-[0.1em] uppercase hover:bg-primary/90 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:[k&&e.jsx(B,{className:"h-3.5 w-3.5 animate-spin"}),k?"Uploading…":`Upload ${v||""}`.trim()]})]})]})]})})}function _n({item:t,onRemove:r,onForce:s}){var n;return e.jsxs("li",{className:"px-4 py-3 flex items-start gap-3",children:[e.jsx(Re,{className:"h-4 w-4 text-muted-foreground flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-body text-[13px] text-foreground truncate",children:t.file.name}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx(Cn,{item:t}),e.jsxs("span",{className:"font-body text-[11px] text-muted-foreground",children:[(t.file.size/1024/1024).toFixed(2)," MB"]})]}),t.status==="duplicate"&&!t.forceUpload&&e.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[e.jsxs("span",{className:"font-body text-[11px] text-muted-foreground",children:["Matches existing brief by ",((n=t.duplicateOf)==null?void 0:n.reason)==="hash"?"file content":"filename","."]}),e.jsx("button",{onClick:s,className:"font-heading-bold text-[10px] tracking-[0.15em] uppercase text-primary hover:text-foreground transition-colors",children:"Upload anyway"})]}),t.status==="failed"&&t.error&&e.jsx("div",{className:"mt-1 font-body text-[11px] text-destructive",children:t.error})]}),(t.status==="queued"||t.status==="duplicate"||t.status==="failed")&&e.jsx("button",{onClick:r,className:"text-muted-foreground hover:text-destructive transition-colors flex-shrink-0","aria-label":"Remove",children:e.jsx(Fe,{className:"h-4 w-4"})})]})}function Cn({item:t}){const r="inline-flex items-center gap-1 px-1.5 py-0.5 font-heading-bold text-[10px] tracking-[0.12em] uppercase";switch(t.status){case"hashing":return e.jsxs("span",{className:`${r} bg-muted text-muted-foreground`,children:[e.jsx(B,{className:"h-3 w-3 animate-spin"})," Scanning"]});case"queued":return e.jsx("span",{className:`${r} bg-primary/10 text-primary border border-primary/30`,children:t.forceUpload?"Ready (forced)":"Ready"});case"duplicate":return e.jsxs("span",{className:`${r} bg-amber-500/10 text-amber-500 border border-amber-500/30`,children:[e.jsx(jt,{className:"h-3 w-3"})," Duplicate"]});case"uploading":return e.jsxs("span",{className:`${r} bg-primary/10 text-primary border border-primary/30`,children:[e.jsx(B,{className:"h-3 w-3 animate-spin"})," Uploading"]});case"uploaded":return e.jsxs("span",{className:`${r} bg-emerald-500/10 text-emerald-500 border border-emerald-500/30`,children:[e.jsx(lt,{className:"h-3 w-3"})," Uploaded"]});case"failed":return e.jsxs("span",{className:`${r} bg-destructive/10 text-destructive border border-destructive/30`,children:[e.jsx(wt,{className:"h-3 w-3"})," Failed"]})}}var Ie="rovingFocusGroup.onEntryFocus",Sn={bubbles:!1,cancelable:!0},xe="RovingFocusGroup",[Te,St,kn]=ut(xe),[Mn,kt]=Le(xe,[kn]),[En,In]=Mn(xe),Mt=a.forwardRef((t,r)=>e.jsx(Te.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Te.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Dn,{...t,ref:r})})}));Mt.displayName=xe;var Dn=a.forwardRef((t,r)=>{const{__scopeRovingFocusGroup:s,orientation:n,loop:o=!1,dir:i,currentTabStopId:f,defaultCurrentTabStopId:p,onCurrentTabStopIdChange:x,onEntryFocus:b,preventScrollOnEntryFocus:m=!1,...u}=t,c=a.useRef(null),g=oe(r,c),j=mt(i),[C,w]=pt({prop:f,defaultProp:p??null,onChange:x,caller:xe}),[v,P]=a.useState(!1),N=$e(b),k=St(s),M=a.useRef(!1),[h,l]=a.useState(0);return a.useEffect(()=>{const y=c.current;if(y)return y.addEventListener(Ie,N),()=>y.removeEventListener(Ie,N)}
vendor: 19,039 bytes, line 41
41,[N]),e.jsx(En,{scope:s,orientation:n,dir:j,loop:o,currentTabStopId:C,onItemFocus:a.useCallback(y=>w(y),[w]),onItemShiftTab:a.useCallback(()=>P(!0),[]),onFocusableItemAdd:a.useCallback(()=>l(y=>y+1),[]),onFocusableItemRemove:a.useCallback(()=>l(y=>y-1),[]),children:e.jsx(X.div,{tabIndex:v||h===0?-1:0,"data-orientation":n,...u,ref:g,style:{outline:"none",...t.style},onMouseDown:I(t.onMouseDown,()=>{M.current=!0}),onFocus:I(t.onFocus,y=>{const T=!M.current;if(y.target===y.currentTarget&&T&&!v){const A=new CustomEvent(Ie,Sn);if(y.currentTarget.dispatchEvent(A),!A.defaultPrevented){const R=k().filter(E=>E.focusable),S=R.find(E=>E.active),O=R.find(E=>E.id===C),D=[S,O,...R].filter(Boolean).map(E=>E.ref.current);Dt(D,m)}}M.current=!1}),onBlur:I(t.onBlur,()=>P(!1))})})}),Et="RovingFocusGroupItem",It=a.forwardRef((t,r)=>{const{__scopeRovingFocusGroup:s,focusable:n=!0,active:o=!1,tabStopId:i,children:f,...p}=t,x=De(),b=i||x,m=In(Et,s),u=m.currentTabStopId===b,c=St(s),{onFocusableItemAdd:g,onFocusableItemRemove:j,currentTabStopId:C}=m;return a.useEffect(()=>{if(n)return g(),()=>j()},[n,g,j]),e.jsx(Te.ItemSlot,{scope:s,id:b,focusable:n,active:o,children:e.jsx(X.span,{tabIndex:u?0:-1,"data-orientation":m.orientation,...p,ref:r,onMouseDown:I(t.onMouseDown,w=>{n?m.onItemFocus(b):w.preventDefault()}),onFocus:I(t.onFocus,()=>m.onItemFocus(b)),onKeyDown:I(t.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){m.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const v=An(w,m.orientation,m.dir);if(v!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let N=c().filter(k=>k.focusable).map(k=>k.ref.current);if(v==="last")N.reverse();else if(v==="prev"||v==="next"){v==="prev"&&N.reverse();const k=N.indexOf(w.currentTarget);N=m.loop?Pn(N,k+1):N.slice(k+1)}setTimeout(()=>Dt(N))}}),children:typeof f=="function"?f({isCurrentTabStop:u,hasTabStop:C!=null}):f})})});It.displayName=Et;var Rn={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Tn(t,r){return r!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function An(t,r,s){const n=Tn(t.key,s);if(!(r==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(r==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return Rn[n]}function Dt(t,r=!1){const s=document.activeElement;for(const n of t)if(n===s||(n.focus({preventScroll:r}),document.activeElement!==s))return}function Pn(t,r){return t.map((s,n)=>t[(r+n)%t.length])}var On=Mt,Fn=It,Ae=["Enter"," "],Ln=["ArrowDown","PageUp","Home"],Rt=["ArrowUp","PageDown","End"],$n=[...Ln,...Rt],Bn={ltr:[...Ae,"ArrowRight"],rtl:[...Ae,"ArrowLeft"]},Un={ltr:["ArrowLeft"],rtl:["ArrowRight"]},he="Menu",[pe,Gn,Kn]=ut(he),[Z,Tt]=Le(he,[Kn,ft,kt]),_e=ft(),At=kt(),[Hn,J]=Z(he),[qn,ge]=Z(he),Pt=t=>{const{__scopeMenu:r,open:s=!1,children:n,dir:o,onOpenChange:i,modal:f=!0}=t,p=_e(r),[x,b]=a.useState(null),m=a.useRef(!1),u=$e(i),c=mt(o);return a.useEffect(()=>{const g=()=>{m.current=!0,document.addEventListener("pointerdown",j,{capture:!0,once:!0}),document.addEventListener("pointermove",j,{capture:!0,once:!0})},j=()=>m.current=!1;return document.addEventListener("keydown",g,{capture:!0}),()=>{document.removeEventListener("keydown",g,{capture:!0}),document.removeEventListener("pointerdown",j,{capture:!0}),document.removeEventListener("pointermove",j,{capture:!0})}},[]),e.jsx(Fr,{...p,children:e.jsx(Hn,{scope:r,open:s,onOpenChange:u,content:x,onContentChange:b,children:e.jsx(qn,{scope:r,onClose:a.useCallback(()=>u(!1),[u]),isUsingKeyboardRef:m,dir:c,modal:f,children:n})})})};Pt.displayName=he;var Vn="MenuAnchor",Ge=a.forwardRef((t,r)=>{const{__scopeMenu:s,...n}=t,o=_e(s);return e.jsx(Mr,{...o,...n,ref:r})});Ge.displayName=Vn;var Ke="MenuPortal",[zn,Ot]=Z(Ke,{forceMount:void 0}),Ft=t=>{const{__scopeMenu:r,forceMount:s,children:n,container:o}=t,i=J(Ke,r);return e.jsx(zn,{scope:r,forceMount:s,children:e.jsx(Ne,{present:s||i.open,children:e.jsx(Lr,{asChild:!0,container:o,children:n})})})};Ft.displayName=Ke;var K="MenuContent",[Yn,He]=Z(K),Lt=a.forwardRef((t,r)=>{const s=Ot(K,t.__scopeMenu),{forceMount:n=s.forceMount,...o}=t,i=J(K,t.__scopeMenu),f=ge(K,t.__scopeMenu);return e.jsx(pe.Provider,{scope:t.__scopeMenu,children:e.jsx(Ne,{present:n||i.open,children:e.jsx(pe.Slot,{scope:t.__scopeMenu,children:f.modal?e.jsx(Xn,{...o,ref:r}):e.jsx(Wn,{...o,ref:r})})})})}),Xn=a.forwardRef((t,r)=>{const s=J(K,t.__scopeMenu),n=a.useRef(null),o=oe(r,n);return a.useEffect(()=>{const i=n.current;if(i)return Er(i)},[]),e.jsx(qe,{...t,ref:o,trapFocus:s.open,disableOutsidePointerEvents:s.open,disableOutsideScroll:!0,onFocusOutside:I(t.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>s.onOpenChange(!1)})}),Wn=a.forwardRef((t,r)=>{const s=J(K,t.__scopeMenu);return e.jsx(qe,{...t,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>s.onOpenChange(!1)})}),Qn=$r("MenuContent.ScrollLock"),qe=a.forwardRef((t,r)=>{const{__scopeMenu:s,loop:n=!1,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:f,disableOutsidePointerEvents:p,onEntryFocus:x,onEscapeKeyDown:b,onPointerDownOutside:m,onFocusOutside:u,onInteractOutside:c,onDismiss:g,disableOutsideScroll:j,...C}=t,w=J(K,s),v=ge(K,s),P=_e(s),N=At(s),k=Gn(s),[M,h]=a.useState(null),l=a.useRef(null),y=oe(r,l,w.onContentChange),T=a.useRef(0),A=a.useRef(""),R=a.useRef(0),S=a.useRef(null),O=a.useRef("right"),d=a.useRef(0),D=j?Pr:a.Fragment,E=j?{as:Qn,allowPinchZoom:!0}:void 0,be=_=>{var te,We;const U=A.current+_,H=k().filter(q=>!q.disabled),V=document.activeElement,ke=(te=H.find(q=>q.ref.current===V))==null?void 0:te.textValue,Me=H.map(q=>q.textValue),Xe=cs(Me,U,ke),ie=(We=H.find(q=>q.textValue===Xe))==null?void 0:We.ref.current;(function q(Qe){A.current=Qe,window.clearTimeout(T.current),Qe!==""&&(T.current=window.setTimeout(()=>q(""),1e3))})(U),ie&&setTimeout(()=>ie.focus())};a.useEffect(()=>()=>window.clearTimeout(T.current),[]),Ir();const ee=a.useCallback(_=>{var H,V;return O.current===((H=S.current)==null?void 0:H.side)&&us(_,(V=S.current)==null?void 0:V.area)},[]);return e.jsx(Yn,{scope:s,searchRef:A,onItemEnter:a.useCallback(_=>{ee(_)&&_.preventDefault()},[ee]),onItemLeave:a.useCallback(_=>{var U;ee(_)||((U=l.current)==null||U.focus(),h(null))},[ee]),onTriggerLeave:a.useCallback(_=>{ee(_)&&_.preventDefault()},[ee]),pointerGraceTimerRef:R,onPointerGraceIntentChange:a.useCallback(_=>{S.current=_},[]),children:e.jsx(D,{...E,children:e.jsx(Dr,{asChild:!0,trapped:o,onMountAutoFocus:I(i,_=>{var U;_.preventDefault(),(U=l.current)==null||U.focus({preventScroll:!0})}),onUnmountAutoFocus:f,children:e.jsx(Rr,{asChild:!0,disableOutsidePointerEvents:p,onEscapeKeyDown:b,onPointerDownOutside:m,onFocusOutside:u,onInteractOutside:c,onDismiss:g,children:e.jsx(On,{asChild:!0,...N,dir:v.dir,orientation:"vertical",loop:n,currentTabStopId:M,onCurrentTabStopIdChange:h,onEntryFocus:I(x,_=>{v.isUsingKeyboardRef.current||_.preventDefault()}),preventScrollOnEntryFocus:!0,children:e.jsx(Tr,{role:"menu","aria-orientation":"vertical","data-state":er(w.open),"data-radix-menu-content":"",dir:v.dir,...P,...C,ref:y,style:{outline:"none",...C.style},onKeyDown:I(C.onKeyDown,_=>{const H=_.target.closest("[data-radix-menu-content]")===_.currentTarget,V=_.ctrlKey||_.altKey||_.metaKey,ke=_.key.length===1;H&&(_.key==="Tab"&&_.preventDefault(),!V&&ke&&be(_.key));const Me=l.current;if(_.target!==Me||!$n.includes(_.key))return;_.preventDefault();const ie=k().filter(te=>!te.disabled).map(te=>te.ref.current);Rt.includes(_.key)&&ie.reverse(),is(ie)}),onBlur:I(t.onBlur,_=>{_.currentTarget.contains(_.target)||(window.clearTimeout(T.current),A.current="")}),onPointerMove:I(t.onPointerMove,fe(_=>{const U=_.target,H=d.current!==_.clientX;if(_.currentTarget.contains(U)&&H){const V=_.clientX>d.current?"right":"left";O.current=V,d.current=_.clientX}}))})})})})})})});Lt.displayName=K;var Zn="MenuGroup",Ve=a.forwardRef((t,r)=>{const{__scopeMenu:s,...n}=t;return e.jsx(X.div,{role:"group",...n,ref:r})});Ve.displayName=Zn;var Jn="MenuLabel",$t=a.forwardRef((t,r)=>{const{__scopeMenu:s,...n}=t;return e.jsx(X.div,{...n,ref:r})});$t.displayName=Jn;var ye="MenuItem",st="menu.itemSelect",Ce=a.forwardRef((t,r)=>{const{disabled:s=!1,onSelect:n,...o}=t,i=a.useRef(null),f=ge(ye,t.__scopeMenu),p=He(ye,t.__scopeMenu),x=oe(r,i),b=a.useRef(!1),m=()=>{const u=i.current;if(!s&&u){const c=new CustomEvent(st,{bubbles:!0,cancelable:!0});u.addEventListener(st,g=>n==null?void 0:n(g),{once:!0}),Or(u,c),c.defaultPrevented?b.current=!1:f.onClose()}};return e.jsx(Bt,{...o,ref:x,disabled:s,onClick:I(t.onClick,m),onPointerDown:u=>{var c;(c=t.onPointerDown)==null||c.call(t,u),b.current=!0},onPointerUp:I(t.onPointerUp,u=>{var c;b.current||(c=u.currentTarget)==null||c.click()}),onKeyDown:I(t.onKeyDown,u=>{const c=p.searchRef.current!=="";s||c&&u.key===" "||Ae.includes(u.key)&&(u.currentTarget.click(),u.preventDefault())})})});Ce.displayName=ye;var Bt=a.forwardRef((t,r)=>{const{__scopeMenu:s,disabled:n=!1,textValue:o,...i}=t,f=He(ye,s),p=At(s),x=a.useRef(null),b=oe(r,x),[m,u]=a.useState(!1),[c,g]=a.useState("");return a.useEffect(()=>{const j=x.current;j&&g((j.textContent??"").trim())},[i.children]),e.jsx(pe.ItemSlot,{scope:s,disabled:n,textValue:o??c,children:e.jsx(Fn,{asChild:!0,...p,focusable:!n,children:e.jsx(X.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...i,ref:b,onPointerMove:I(t.onPointerMove,fe(j=>{n?f.onItemLeave(j):(f.onItemEnter(j),j.defaultPrevented||j.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:I(t.onPointerLeave,fe(j=>f.onItemLeave(j))),onFocus:I(t.onFocus,()=>u(!0)),onBlur:I(t.onBlur,()=>u(!1))})})})}),es="MenuCheckboxItem",Ut=a.forwardRef((t,r)=>{const{checked:s=!1,onCheckedChange:n,...o}=t;return e.jsx(Vt,{scope:t.__scopeMenu,checked:s,children:e.jsx(Ce,{role:"menuitemcheckbox","aria-checked":je(s)?"mixed":s,...o,ref:r,"data-state":Ye(s),onSelect:I(o.onSelect,()=>n==null?void 0:n(je(s)?!0:!s),{checkForDefaultPrevented:!1})})})});Ut.displayName=es;var Gt="MenuRadioGroup",[ts,rs]=Z(Gt,{value:void 0,onValueChange:()=>{}}),Kt=a.forwardRef((t,r)=>{const{value:s,onValueChange:n,...o}=t,i=$e(n);return e.jsx(ts,{scope:t.__scopeMenu,value:s,onValueChange:i,children:e.jsx(Ve,{...o,ref:r})})});Kt.displayName=Gt;var Ht="MenuRadioItem",qt=a.forwardRef((t,r)=>{const{value:s,...n}=t,o=rs(Ht,t.__scopeMenu),i=s===o.value;return e.jsx(Vt,{scope:t.__scopeMenu,checked:i,children:e.jsx(Ce,{role:"menuitemradio","aria-checked":i,...n,ref:r,"data-state":Ye(i),onSelect:I(n.onSelect,()=>{var f;return(f=o.onValueChange)==null?void 0:f.call(o,s)},{checkForDefaultPrevented:!1})})})});qt.displayName=Ht;var ze="MenuItemIndicator",[Vt,ns]=Z(ze,{checked:!1}),zt=a.forwardRef((t,r)=>{const{__scopeMenu:s,forceMount:n,...o}=t,i=ns(ze,s);return e.jsx(Ne,{present:n||je(i.checked)||i.checked===!0,children:e.jsx(X.span,{...o,ref:r,"data-state":Ye(i.checked)})})});zt.displayName=ze;var ss="MenuSeparator",Yt=a.forwardRef((t,r)=>{const{__scopeMenu:s,...n}=t;return e.jsx(X.div,{role:"separator","aria-orientation":"horizontal",...n,ref:r})});Yt.displayName=ss;var as="MenuArrow",Xt=a.forwardRef((t,r)=>{const{__scopeMenu:s,...n}=t,o=_e(s);return e.jsx(Ar,{...o,...n,ref:r})});Xt.displayName=as;var os="MenuSub",[fa,Wt]=Z(os),ce="MenuSubTrigger",Qt=a.forwardRef((t,r)=>{const s=J(ce,t.__scopeMenu),n=ge(ce,t.__scopeMenu),o=Wt(ce,t.__scopeMenu),i=He(ce,t.__scopeMenu),f=a.useRef(null),{pointerGraceTimerRef:p,onPointerGraceIntentChange:x}=i,b={__scopeMenu:t.__scopeMenu},m=a.useCallback(()=>{f.current&&window.clearTimeout(f.current),f.current=null},[]);return a.useEffect(()=>m,[m]),a.useEffect(()=>{const u=p.current;return()=>{window.clearTimeout(u),x(null)}},[p,x]),e.jsx(Ge,{asChild:!0,...b,children:e.jsx(Bt,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":o.contentId,"data-state":er(s.open),...t,ref:xt(r,o.onTriggerChange),onClick:u=>{var c;(c=t.onClick)==null||c.call(t,u),!(t.disabled||u.defaultPrevented)&&(u.currentTarget.focus(),s.open||s.onOpenChange(!0))},onPointerMove:I(t.onPointerMove,fe(u=>{i.onItemEnter(u),!u.defaultPrevented&&!t.disabled&&!s.open&&!f.current&&(i.onPointerGraceIntentChange(null),f.current=window.setTimeout(()=>{s.onOpenChange(!0),m()},100))})),onPointerLeave:I(t.onPointerLeave,fe(u=>{var g,j;m();const c=(g=s.content)==null?void 0:g.getBoundingClientRect();if(c){const C=(j=s.content)==null?void 0:j.dataset.side,w=C==="right",v=w?-5:5,P=c[w?"left":"right"],N=c[w?"right":"left"];i.onPointerGraceIntentChange({area:[{x:u.clientX+v,y:u.clientY},{x:P,y:c.top},{x:N,y:c.top},{x:N,y:c.bottom},{x:P,y:c.bottom}],side:C}),window.clearTimeout(p.current),p.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(u),u.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:I(t.onKeyDown,u=>{var g;const c=i.searchRef.current!=="";t.disabled||c&&u.key===" "||Bn[n.dir].includes(u.key)&&(s.onOpenChange(!0),(g=s.content)==null||g.focus(),u.preventDefault())})})})});Qt.displayName=ce;var Zt="MenuSubContent",Jt=a.forwardRef((t,r)=>{const s=Ot(K,t.__scopeMenu),{forceMount:n=s.forceMount,...o}=t,i=J(K,t.__scopeMenu),f=ge(K,t.__scopeMenu),p=Wt(Zt,t.__scopeMenu),x=a.useRef(null),b=oe(r,x);return e.jsx(pe.Provider,{scope:t.__scopeMenu,children:e.jsx(Ne,{present:n||i.open,children:e.jsx(pe.Slot,{scope:t.__scopeMenu,children:e.jsx(qe,{id:p.contentId,"aria-labelledby":p.triggerId,...o,ref:b,align:"start",side:f.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:m=>{var u;f.isUsingKeyboardRef.current&&((u=x.current)==null||u.focus()),m.preventDefault()},onCloseAutoFocus:m=>m.preventDefault(),onFocusOutside:I(t.onFocusOutside,m=>{m.target!==p.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:I(t.onEscapeKeyDown,m=>{f.onClose(),m.preventDefault()}),onKeyDown:I(t.onKeyDown,m=>{var g;const u=m.currentTarget.contains(m.target),c=Un[f.dir].includes(m.key);u&&c&&(i.onOpenChange(!1),(g=p.trigger)==null||g.focus(),m.preventDefault())})})})})})});Jt.displayName=Zt;function er(t){return t?"open":"closed"}function je(t){return t==="indeterminate"}function Ye(t){return je(t)?"indeterminate":t?"checked":"unchecked"}function is(t){const r=document.activeElement;for(const s of t)if(s===r||(s.focus(),document.activeElement!==r))return}function ds(t,r){return t.map((s,n)=>t[(r+n)%t.length])}function cs(t,r,s){const o=r.length>1&&Array.from(r).every(b=>b===r[0])?r[0]:r,i=s?t.indexOf(s):-1;let f=ds(t,Math.max(i,0));o.length===1&&(f=f.filter(b=>b!==s));const x=f.find(b=>b.toLowerCase().startsWith(o.toLowerCase()));return x!==s?x:void 0}function ls(t,r){const{x:s,y:n}=t;let o=!1;for(let i=0,f=r.length-1;i<r.length;f=i++){const p=r[i],x=r[f],b=p.x,m=p.y,u=x.x,c=x.y;m>n!=c>n&&s<(u-b)*(n-m)/(c-m)+b&&(o=!o)}return o}function us(t,r){if(!r)return!1;const s={x:t.clientX,y:t.clientY};return ls(s,r)}function fe(t){return r=>r.pointerType==="mouse"?t(r):void 0}var ms=Pt,ps=Ge,fs=Ft,xs=Lt,hs=Ve,gs=$t,bs=Ce,vs=Ut,ys=Kt,js=qt,ws=zt,Ns=Yt,_s=Xt,Cs=Qt,Ss=Jt,Se="DropdownMenu",[ks,xa]=Le(Se,[Tt]),$=Tt(),[Ms,tr]=ks(Se),rr=t=>{const{__scopeDropdownMenu:r,children:s,dir:n,open:o,defaultOpen:i,onOpenChange:f,modal:p=!0}=t,x=$(r),b=a.useRef(null),[m,u]=pt({prop:o,defaultProp:i??!1,onChange:f,caller:Se});return e.jsx(Ms,{scope:r,triggerId:De(),triggerRef:b,contentId:De(),open:m,onOpenChange:u,onOpenToggle:a.useCallback(()=>u(c=>!c),[u]),modal:p,children:e.jsx(ms,{...x,open:m,onOpenChange:u,dir:n,modal:p,children:s})})};rr.displayName=Se;var nr="DropdownMenuTrigger",sr=a.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,disabled:n=!1,...o}=t,i=tr(nr,s),f=$(s);return e.jsx(ps,{asChild:!0,...f,children:e.jsx(X.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":n?"":void 0,disabled:n,...o,ref:xt(r,i.triggerRef),onPointerDown:I(t.onPointerDown,p=>{!n&&p.button===0&&p.ctrlKey===!1&&(i.onOpenToggle(),i.open||p.preventDefault())}),onKeyDown:I(t.onKeyDown,p=>{n||(["Enter"," "].includes(p.key)&&i.onOpenToggle(),p.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(p.key)&&p.preventDefault())})})})});sr.displayName=nr;var Es="DropdownMenuPortal",ar=t=>{const{__scopeDropdownMenu:r,...s}=t,n=$(r);return e.jsx(fs,{...n,...s})};ar.displayName=Es;var or="DropdownMenuContent",ir=a.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...n}=t,o=tr(or,s),i=$(s),f=a.useRef(!1);return e.jsx(xs,{id:o.contentId,"aria-labelledby":o.triggerId,...i,...n,ref:r,onCloseAutoFocus:I(t.onCloseAutoFocus,p=>{var x;f.current||(x=o.triggerRef.current)==null||x.focus(),f.current=!1,p.preventDefault()}),onInteractOutside:I(t.onInteractOutside,p=>{const x=p.detail.originalEvent,b=x.button===0&&x.ctrlKey===!0,m=x.button===2||b;(!o.modal||m)&&(f.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});ir.displayName=or;var Is="DropdownMenuGroup",Ds=a.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...n}=t,o=$(s);return e.jsx(hs,{...o,...n,ref:r})});Ds.displayName=Is;var Rs="DropdownMenuLabel",dr=a.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...n}=t,o=$(s);return e.jsx(gs,{...o,...n,ref:r})});dr.displayName=Rs;var Ts="DropdownMenuItem",cr=a.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...n}=t,o=$(s);return e.jsx(bs,{...o,...n,ref:r})});cr.displayName=Ts;var As="DropdownMenuCheckboxItem",lr=a.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...n}=t,o=$(s);return e.jsx(vs,{...o,...n,ref:r})});lr.displayName=As;var Ps="DropdownMenuRadioGroup",Os=a.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...n}=t,o=$(s);return e.jsx(ys,{...o,...n,ref:r})});Os.displayName=Ps;var Fs="DropdownMenuRadioItem",ur=a.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...n}=t,o=$(s);return e.jsx(js,{...o,...n,ref:r})});ur.displayName=Fs;var Ls="DropdownMenuItemIndicator",mr=a.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...n}=t,o=$(s);return e.jsx(ws,{...o,...n,ref:r})});mr.displayName=Ls;var $s="DropdownMenuSeparator",pr=a.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...n}=t,o=$(s);return e.jsx(Ns,{...o,...n,ref:r})});pr.displayName=$s;var Bs="DropdownMenuArrow",Us=a.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...n}=t,o=$(s);return e.jsx(_s,{...o,...n,ref:r})});Us.displayName=Bs;var Gs="DropdownMenuSubTrigger",fr=a.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...n}=t,o=$(s);return e.jsx(Cs,{...o,...n,ref:r})});fr.displayName=Gs;var Ks="DropdownMenuSubContent",xr=a.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...n}=t,o=$(s);
41return e.jsx(Ss,{...o,...n,ref:r,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});xr.displayName=Ks;var Hs=rr,qs=sr,Vs=ar,hr=ir,gr=dr,br=cr,vr=lr,yr=ur,jr=mr,wr=pr,Nr=fr,_r=xr;const zs=Hs,Ys=qs,Xs=a.forwardRef(({className:t,inset:r,children:s,...n},o)=>e.jsxs(Nr,{ref:o,className:W("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent",r&&"pl-8",t),...n,children:[s,e.jsx(dn,{className:"ml-auto h-4 w-4"})]}));Xs.displayName=Nr.displayName;const Ws=a.forwardRef(({className:t,...r},s)=>e.jsx(_r,{ref:s,className:W("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r}));Ws.displayName=_r.displayName;const Cr=a.forwardRef(({className:t,sideOffset:r=4,...s},n)=>e.jsx(Vs,{children:e.jsx(hr,{ref:n,sideOffset:r,className:W("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...s})}));Cr.displayName=hr.displayName;const se=a.forwardRef(({className:t,inset:r,...s},n)=>e.jsx(br,{ref:n,className:W("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",r&&"pl-8",t),...s}));se.displayName=br.displayName;const Qs=a.forwardRef(({className:t,children:r,checked:s,...n},o)=>e.jsxs(vr,{ref:o,className:W("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),checked:s,...n,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(jr,{children:e.jsx(Br,{className:"h-4 w-4"})})}),r]}));Qs.displayName=vr.displayName;const Zs=a.forwardRef(({className:t,children:r,...s},n)=>e.jsxs(yr,{ref:n,className:W("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(jr,{children:e.jsx(mn,{className:"h-2 w-2 fill-current"})})}),r]}));Zs.displayName=yr.displayName;const Pe=a.forwardRef(({className:t,inset:r,...s},n)=>e.jsx(gr,{ref:n,className:W("px-2 py-1.5 text-sm font-semibold",r&&"pl-8",t),...s}));Pe.displayName=gr.displayName;const Oe=a.forwardRef(({className:t,...r},s)=>e.jsx(wr,{ref:s,className:W("-mx-1 my-1 h-px bg-muted",t),...r}));Oe.displayName=wr.displayName;function at(t){return t.is_published?"published":t.extraction_status==="pending"?"extraction_pending":t.extraction_status==="processing"?"processing":t.extraction_status==="failed"?"failed":t.extraction_status==="complete"?"complete":"draft"}const Js={draft:"DRAFT",published:"PUBLISHED",extraction_pending:"EXTRACTION PENDING",processing:"PROCESSING",failed:"FAILED",complete:"READY TO PUBLISH"};function ot({status:t}){const r={published:"border-primary/50 bg-primary/10 text-primary",draft:"border-border bg-muted/40 text-muted-foreground",extraction_pending:"border-border bg-muted/40 text-muted-foreground",processing:"border-primary/30 bg-primary/5 text-primary/90",failed:"border-destructive/40 bg-destructive/10 text-destructive",complete:"border-foreground
41/20 bg-foreground/5 text-foreground"};return e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 border font-heading-bold text-[10px] tracking-[0.15em] uppercase ${r[t]}`,children:[t==="processing"&&e.jsx(B,{className:"h-3 w-3 animate-spin"}),t==="failed"&&e.jsx(wt,{className:"h-3 w-3"}),t==="published"&&e.jsx(lt,{className:"h-3 w-3"}),Js[t]]})}function de(t){if(!t)return"";try{return new Date(t).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}catch{return t}}function it({brief:t}){const r=t.notification_send_count??0,s=t.notification_sent_at,n=t.scheduled_send_at,o=r>0,i=!o&&!!n&&new Date(n).getTime()>Date.now(),f=o?r===1?`Email sent ${de(s)}`:`Email sent ${r}× · last ${de(s)}`:i?`Email scheduled for ${de(n)}`:"Email not sent",p=e.jsxs("div",{className:"font-body text-[12px] leading-snug space-y-0.5",children:[e.jsx("div",{className:"font-heading-bold tracking-[0.12em] uppercase text-[10px] opacity-70",children:"Notification Status"}),o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:["Sends: ",r]}),e.jsxs("div",{children:["Last sent: ",de(s)||", "]}),e.jsxs("div",{className:"opacity-70",children:["Triggered by: ",t.last_notification_by?`admin ${t.last_notification_by.slice(0,8)}…`:", "]})]}):i?e.jsxs("div",{children:["Scheduled to send at ",de(n),"."]}):e.jsx("div",{children:"No member notification has been sent for this briefing."})]}),x=o?ln:i?un:Ue,b=o?"text-foreground/80":i?"text-amber-500":"text-muted-foreground/70",m=o?"text-primary/80":i?"text-amber-500":"";return e.jsx(ht,{delayDuration:150,children:e.jsxs(gt,{children:[e.jsx(bt,{asChild:!0,children:e.jsxs("span",{className:`inline-flex items-center gap-1.5 font-body text-[11px] leading-tight ${b}`,children:[e.jsx(x,{className:`h-3.5 w-3.5 shrink-0 ${m}`}),e.jsx("span",{className:"truncate",children:f})]})}),e.jsx(vt,{side:"top",className:"max-w-xs",children:p})]})})}function ha(){const t=Ur(),{isAdmin:r,loading:s}=Gr(),{data:n,isLoading:o,refetch:i}=Qr(),f=Zr(),[p,x]=a.useState(!1),[b,m]=a.useState(null),[u,c]=a.useState(null),[g,j]=a.useState(null),[C,w]=a.useState(null),[v,P]=a.useState(null),[N,k]=a.useState(null),M=a.useMemo(()=>n?[...n].sort((l,y)=>{const T=l.publish_date??l.created_at;return(y.publish_date??y.created_at).localeCompare(T)}):[],[n]),h=async l=>{j(l.id);try{await L.from("intel_briefs").update({extraction_status:"pending",extraction_error:null}).eq("id",l.id),await L.functions.invoke("intel-extract-metadata",{body:{brief_id:l.id}}),F({title:"Re-extraction queued",description:"AI is reading the brief again."}),i()}catch(y){F({title:"Failed to re-extract",description:y instanceof Error?y.message:"Try again.",variant:"destructive"})}finally{j(null)}};return s?e.jsx(e.Fragment,{children:e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(B,{className:"h-6 w-6 animate-spin text-primary"})})}):r?e.jsxs(e.Fragment,{children:[e.jsx(Kr,{children:e.jsx("title",{children:"Manage Intelligence Briefings | Dangerous Gentleman"})}),e.jsxs("div",{className:"mb-6 flex items-center gap-2 text-[11px] font-heading-bold tracking-[0.2em] uppercase text-muted-foreground",children:[e.jsxs("button",{onClick:()=>t("/dashboard/admin"),className:"inline-flex items-center gap-1 hover:text-foreground transition-colors",children:[e.jsx(Hr,{className:"h-3 w-3"})," Admin"]}),e.jsx("span",{children:"/"}),e.jsx("span",{className:"text-foreground",children:"Intelligence Briefings"})]}),e.jsxs("header",{className:"mb-8 flex flex-col md:flex-row md:items-end md:justify-between gap-4",children:[e.jsxs("div",{className:"max-w-2xl",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3 text-[11px] font-heading-bold tracking-[0.2em] text-primary uppercase",children:[e.jsx(Ze,{className:"h-3.5 w-3.5"})," Admin"]}),e.jsx("h1",{className:"font-heading-bold text-[28px] md:text-[34px] tracking-[0.02em] text-foreground leading-tight",children:"Manage Intelligence Briefings"}),e.jsx("p",{className:"mt-2 font-body text-[14px] text-muted-foreground",children:"Upload weekly briefs. AI extracts metadata for your review before publishing."})]}),e.jsxs(we,{as:"button",onClick:()=>{m(null),x(!0)},className:"text-primary-foreground self-start md:self-auto",outerClassName:"bg-primary",innerClassName:"bg-primary group-hover:bg-primary/90",contentClassName:"px-5 py-3 font-heading-bold text-[12px] tracking-[0.15em] inline-flex items-center gap-2",children:[e.jsx(qr,{className:"h-4 w-4"})," NEW INTELLIGENCE BRIEF"]})]}),o?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(B,{className:"h-6 w-6 animate-spin text-primary"})}):M.length===0?e.jsxs("div",{className:"border border-dashed border-border bg-card p-10 text-center max-w-xl",children:[e.jsx(Ze,{className:"mx-auto h-8 w-8 text-muted-foreground mb-3"}),e.jsx("h3",{className:"font-heading-bold text-[16px] text-foreground mb-1",children:"No briefs yet"}),e.jsx("p",{className:"font-body text-[13px] text-muted-foreground",children:'Click "New Intelligence Brief" to upload your first PDF.'})]}):e.jsxs("div",{className:"border border-border bg-card overflow-hidden",children:[e.jsx("div",{className:"hidden md:block overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{className:"bg-muted/30 border-b border-border",children:e.jsxs("tr",{className:"font-heading-bold text-[10px] tracking-[0.15em] uppercase text-muted-foreground",children:[e.jsx("th",{className:"px-4 py-3 w-16",children:"Issue"}),e.jsx("th",{className:"px-4 py-3",children:"Title"}),e.jsx("th",{className:"px-4 py-3 w-32",children:"Date"}),e.jsx("th",{className:"px-4 py-3 w-44",children:"Status"}),e.jsx("th",{className:"px-4 py-3 w-56 text-right",children:"Actions"})]})}
41),e.jsx("tbody",{children:M.map(l=>{const y=at(l),T=l.title??l.extracted_title??l.pdf_filename,A=l.issue_number??l.extracted_issue_number,R=l.publish_date??l.extracted_publish_date;return e.jsxs("tr",{className:"border-b border-border last:border-0 hover:bg-muted/20 transition-colors",children:[e.jsx("td",{className:"px-4 py-3 font-heading-bold text-[13px] text-foreground",children:A?`#${A}`:", "}),e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("div",{className:"font-heading-bold text-[9px] tracking-[0.22em] uppercase text-muted-foreground/70",children:l.series_name??l.extracted_series_name??"Strength Through Awareness"}),e.jsx("div",{className:"font-heading-bold text-[14px] text-foreground line-clamp-1",children:T}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5 text-[11px] text-muted-foreground font-body",children:[e.jsx(Re,{className:"h-3 w-3"}),e.jsx("span",{className:"line-clamp-1",children:l.pdf_filename})]}),e.jsx("div",{className:"mt-1.5",children:e.jsx(it,{brief:l})})]}),e.jsx("td",{className:"px-4 py-3 font-body text-[13px] text-muted-foreground",children:R??", "}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(ot,{status:y})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("div",{className:"flex items-center justify-end gap-1.5",children:e.jsx(dt,{brief:l,reExtracting:g===l.id,onView:()=>t(`/dashboard/intel/${l.issue_number}`),onEdit:()=>{m(l.id),x(!0)},onPreviewEmail:()=>w(l.id),onTestEmail:()=>P(l.id),onSendNotification:()=>k(l),onReExtract:()=>h(l),onDelete:()=>c(l)})})})]},l.id)})})]})}),e.jsx("div",{className:"md:hidden divide-y divide-border",children:M.map(l=>{const y=at(l),T=l.title??l.extracted_title??l.pdf_filename,A=l.issue_number??l.extracted_issue_number,R=l.publish_date??l.extracted_publish_date;return e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-heading-bold text-[10px] tracking-[0.22em] uppercase text-muted-foreground/70",children:l.series_name??l.extracted_series_name??"Strength Through Awareness"}),e.jsx("div",{className:"mt-0.5 font-heading-bold text-[15px] text-foreground line-clamp-2",children:T}),e.jsxs("div",{className:"mt-1 font-heading-bold text-[11px] tracking-[0.15em] uppercase text-muted-foreground",children:[A?`Issue #${A}`:"No issue #"," · ",R??", "]})]}),e.jsx(ot,{status:y})]}),e.jsxs("div",{className:"mt-1 mb-2 flex items-center gap-1.5 text-[11px] text-muted-foreground font-body",children:[e.jsx(Re,{className:"h-3 w-3"}),e.jsx("span",{className:"line-clamp-1",children:l.pdf_filename})]}),e.jsx("div",{className:"mb-3",children:e.jsx(it,{brief:l})}),e.jsx("div",{className:"flex items-center justify-end gap-1.5",children:e.jsx(dt,{brief:l,reExtracting:g===l.id,compact:!0,onView:()=>t(`/dashboard/intel/${l.issue_number}`),onEdit:()=>{m(l.id),x(!0)},onPreviewEmail:()=>w(l.id),onTestEmail:()=>P(l.id),onSendNotification:()=>k(l),onReExtract:()=>h(l),onDelete:()=>c(l)})})]},l.id)})})]}),e.jsx(Nn,{open:p,editingBriefId:b,onClose:()=>{x(!1),m(null)},onSaved:()=>{x(!1),m(null),i()}}),e.jsx(Jr,{open:!!u,onOpenChange:l=>!l&&c(null),children:e.jsxs(en,{className:"bg-background border-border rounded-none",children:[e.jsxs(tn,{children:[e.jsx(rn,{className:"font-heading-bold tracking-[0.04em]",children:"Delete this brief?"}),e.jsx(nn,{className:"font-body text-[13px] text-muted-foreground",children:"This permanently removes the brief and its PDF from storage. This cannot be undone."})]}),e.jsxs(sn,{children:[e.jsx(an,{className:"rounded-none",children:"Cancel"}),e.jsx(on,{className:"rounded-none bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:async()=>{if(u)try{await f.mutateAsync({id:u.id,pdf_path:u.pdf_path}),F({title:"Brief deleted"})}catch(l){F({title:"Delete failed",description:l instanceof Error?l.message:"Try again.",variant:"destructive"})}finally{c(null)}},children:"Delete"})]})]})}),e.jsx(Nt,{open:!!C,briefId:C,onClose:()=>w(null)}),e.jsx(_t,{open:!!v,briefId:v,onClose:()=>P(null)}),e.jsx(Ct,{open:!!N,brief:N,onClose:()=>k(null),onSent:()=>i()})]}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"border border-border bg-card p-8 max-w-xl",children:[e.jsx("h2",{className:"font-heading-bold text-[18px] text-foreground mb-2",children:"Access Denied"}),e.jsx("p",{className:"font-body text-[13px] text-muted-foreground",children:"This area is restricted to administrators."})]})})}function ne({children:t,onClick:r,title:s,disabled:n,destructive:o,accent:i}){const f=e.jsx("button",{type:"button","aria-label":s,disabled:n,onClick:r,className:`inline-flex h-8 w-8 items-center justify-center border bg-background transition-colors disabled:opacity-50 ${o?"border-border text-muted-foreground hover:text-destructive hover:border-destructive/50":i?"border-primary/40 text-primary hover:bg-primary/10":"border-border text-muted-foreground hover:text-foreground hover:border-foreground
41/30"}`,children:t});return e.jsx(ht,{delayDuration:150,children:e.jsxs(gt,{children:[e.jsx(bt,{asChild:!0,children:f}),e.jsx(vt,{side:"top",className:"font-heading-bold text-[10px] tracking-[0.15em] uppercase",children:s})]})})}function dt({brief:t,reExtracting:r,compact:s=!1,onView:n,onEdit:o,onPreviewEmail:i,onTestEmail:f,onSendNotification:p,onReExtract:x,onDelete:b}){const m=t.is_published&&!!t.issue_number,u=t.is_published,g=(t.notification_send_count??0)>0?"Resend Email":"Email Members";return s?e.jsxs(e.Fragment,{children:[m&&e.jsx(ne,{title:"View Brief",onClick:n,children:e.jsx(tt,{className:"h-3.5 w-3.5"})}),u&&e.jsx(ne,{title:g,accent:!0,onClick:p,children:e.jsx(ae,{className:"h-3.5 w-3.5"})}),e.jsx(ne,{title:"Edit Brief",onClick:o,children:e.jsx(et,{className:"h-3.5 w-3.5"})}),e.jsx(ct,{brief:t,reExtracting:r,onPreviewEmail:i,onTestEmail:f,onReExtract:x,onDelete:b})]}):e.jsxs(e.Fragment,{children:[m&&e.jsx(ne,{title:"View Brief",onClick:n,children:e.jsx(tt,{className:"h-3.5 w-3.5"})}),u&&e.jsx(ne,{title:g,accent:!0,onClick:p,children:e.jsx(ae,{className:"h-3.5 w-3.5"})}),e.jsx(ne,{title:"Edit Brief",onClick:o,children:e.jsx(et,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:"mx-1 h-5 w-px bg-border","aria-hidden":!0}),e.jsx(ct,{brief:t,reExtracting:r,onPreviewEmail:i,onTestEmail:f,onReExtract:x,onDelete:b})]})}function ct({brief:t,reExtracting:r,onPreviewEmail:s,onTestEmail:n,onReExtract:o,onDelete:i}){const f=t.notification_send_count??0,p=t.notification_sent_at;return e.jsxs(zs,{children:[e.jsx(Ys,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":"More actions",className:"inline-flex h-8 w-8 items-center justify-center border border-border bg-background text-muted-foreground hover:text-foreground hover:border-foreground
41/30 transition-colors",children:e.jsx(pn,{className:"h-4 w-4"})})}),e.jsxs(Cr,{align:"end",className:"w-56 rounded-none border-border bg-card font-body",children:[e.jsx(Pe,{className:"font-heading-bold text-[10px] tracking-[0.18em] uppercase text-muted-foreground",children:"Email Tools"}),e.jsxs(se,{onClick:s,className:"cursor-pointer text-[13px]",children:[e.jsx(Ue,{className:"mr-2 h-3.5 w-3.5"})," Preview Email"]}),e.jsxs(se,{onClick:n,className:"cursor-pointer text-[13px]",children:[e.jsx(ae,{className:"mr-2 h-3.5 w-3.5"})," Send Test Email"]}),f>0&&e.jsxs(se,{disabled:!0,className:"text-[12px] text-muted-foreground",children:[e.jsx(Yr,{className:"mr-2 h-3.5 w-3.5"}),"Sent ",f,"× · ",p?new Date(p).toLocaleDateString():", "]}),e.jsx(Oe,{}),e.jsx(Pe,{className:"font-heading-bold text-[10px] tracking-[0.18em] uppercase text-muted-foreground",children:"Content"}),e.jsxs(se,{onClick:o,disabled:r,className:"cursor-pointer text-[13px]",children:[r?e.jsx(B,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):e.jsx(cn,{className:"mr-2 h-3.5 w-3.5"}),"Re-extract with AI"]}),e.jsx(Oe,{}),e.jsxs(se,{onClick:i,className:"cursor-pointer text-[13px] text-destructive focus:text-destructive focus:bg-destructive/10",children:[e.jsx(Vr,{className:"mr-2 h-3.5 w-3.5"})," Delete Brief"]})]})]})}export{ha as default};

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.