PageSourceSearch

https://www.kerstin-lindquist.com/assets/RunsSection-B68cFztH.js

js kerstin-lindquist.com collected 2026-10-02 15:54:55 UTC 27,179 bytes, 2 lines download raw bytes

1import{r,j as e}from"./vendor-react-B3Dn138K.js";import{q as Xe}from"./index-I4X3YV8i.js";import{c as x,d as f,C as ze,a as Ee,N as w,w as Y,f as B,b as y,e as C,i as j,E as Re,H as Ze,S as et,r as te}from"./Communications-DI2RgdsC.js";import{A as tt}from"./arrow-left-6-8DILbA.js";import{L as k}from"./loader-circle-CYEPF568.js";import{P as st}from"./pencil-BGlYmEEK.js";import{U as at}from"./user-plus-DswU0ijG.js";import{S as Q}from"./send-D5zlgpst.js";import{C as Ae}from"./circle-x-C7DR3Fh-.js";import{T as X}from"./triangle-alert-BIMvG_N-.js";import{R as Fe}from"./refresh-cw-CxqNxCzV.js";import{C as nt}from"./circle-check-Cx8fRHMd.js";import"./vendor-query-CUmDu-Jt.js";import"./vendor-clerk-B6W-q01Q.js";import"./vendor-motion-D-LevzbG.js";import"./users-D1MIzPG9.js";import"./book-open-Bwl1WStG.js";import"./at-sign-kH1VVWaF.js";import"./file-text-B49PnjW-.js";import"./film-BSHQoTwX.js";import"./share-2--GhdISzP.js";import"./settings-Ykvb5QeE.js";const rt=["queued","processing","needs_review","manual_review","ready","awaiting_approval","test_sent","sent","failed","skipped","cancelled"],lt=["guest_prep","post_recording","episode_live","internal_completion"];function $e(n){return n.name?`${n.name} <${n.email}>`:n.email}function z(n){return(n||[]).map($e).join(`
2`)}function Z(n,c){return n.split(/\r?\n/).map(d=>d.trim()).filter(Boolean).map((d,F)=>{const M=d.match(/^(.*?)\s*<([^<>]+)>$/);if(M){const N=M[1].trim();return{email:M[2].trim(),...N?{name:N}:{}}}if(d.includes("<")||d.includes(">"))throw new Error(`${c} line ${F+1} must be an email or Name <email>`);return{email:d}})}function Me(n){return n.status==="test_sent"||n.triggerType==="manual_test"||n.testMode&&n.actualToJson!==null}function ee({label:n,intended:c,actual:d}){return(!c||c.length===0)&&(!d||d.length===0)?null:e.jsxs("div",{className:"grid sm:grid-cols-2 gap-2 text-sm",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:["Intended ",n]}),e.jsx("p",{className:"break-words",children:te(c)})]}),e.jsxs("div",{children:[e.jsxs("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:["Actually sent ",n]}),e.jsx("p",{className:"break-words",children:te(d)})]})]})}function Rt({settings:n}){const{getAuthHeaders:c}=Xe(),d=r.useRef(0),[F,M]=r.useState(null),[N,se]=r.useState(""),[q,_e]=r.useState(""),[ae,l]=r.useState(null),[s,v]=r.useState(null),[ne,D]=r.useState(null),[Be,re]=r.useState(!1),[qe,P]=r.useState(!1),[le,U]=r.useState(null),[o,u]=r.useState(!1),[ie,de]=r.useState(!1),[oe,g]=r.useState(null),[$,T]=r.useState(!1),[S,E]=r.useState(!1),[ce,J]=r.useState(""),[ue,L]=r.useState(!1),[me,I]=r.useState(null),[R,H]=r.useState(""),[A,W]=r.useState(""),[De,pe]=r.useState(""),[Pe,xe]=r.useState(""),[he,fe]=r.useState(""),[ge,be]=r.useState(""),[we,je]=r.useState(""),[ve,Ue]=r.useState(""),K=R!==De||A!==Pe,p=r.useCallback(async()=>{try{const t=new URLSearchParams;N&&t.set("status",N),q&&t.set("workflowType",q),t.set("limit","50");const i=await x(`/runs?${t}`,c);M(i.runs)}catch(t){l(t.message)}},[N,q]);r.useEffect(()=>{p();const t=window.setInterval(()=>{p()},15e3);return()=>window.clearInterval(t)},[p]);const V=async t=>{const i=++d.current;re(!0),P(!1),U(null),de(!1),T(!1),E(!1),g(null),l(null);try{const a=await x(`/runs/${t}`,c);if(i!==d.current)return;v(a.run),D(a.previewHtml),J(a.editableMessageText),L(a.contentEditable),I(a.contentEditBlockReason)}catch(a){i===d.current&&l(a.message)}finally{i===d.current&&re(!1)}};r.useEffect(()=>{if(!s||$||S||o)return;const t=s.id,i=d.current;let a=!0;const b=window.setInterval(async()=>{try{const m=await x(`/runs/${t}`,c);if(!a||i!==d.current)return;v(O=>O?.id===t?m.run:O),D(m.previewHtml),J(m.editableMessageText),L(m.contentEditable),I(m.contentEditBlockReason)}catch{}},15e3);return()=>{a=!1,window.clearInterval(b)}},[s?.id,$,S,o]);const Je=async()=>{if(!(!s||!le)){u(!0),l(null);try{const t=await x(`/runs/${s.id}/resend`,c,{method:"POST",body:{confirm:!0,requestKey:le}});if(P(!1),U(null),!["sent","test_sent"].includes(t.run.status.toLowerCase())){await V(t.run.id),t.run.errorMessage||l(`The replacement email was not confirmed sent (run status: ${t.run.status}).`),await p(),u(!1);return}v(null),await p()}catch(t){l(t.message)}u(!1)}},Le=async()=>
2{if(s){u(!0),l(null);try{await x(`/runs/${s.id}/cancel`,c,{method:"POST"}),v(null),await p()}catch(t){l(t.message)}u(!1)}},G=async t=>{const i=++d.current,a=await x(`/runs/${t}`,c);i===d.current&&(v(a.run),D(a.previewHtml),J(a.editableMessageText),L(a.contentEditable),I(a.contentEditBlockReason))},Ne=async t=>{if(t.status!=="queued")return t;u(!0),++d.current;try{const a={...(await x(`/runs/${t.id}/hold-for-edit`,c,{method:"POST",body:{confirm:!0,expectedUpdatedAt:t.updatedAt}})).run,preparedSenderEmail:t.preparedSenderEmail,preparedSenderUpdatedAt:t.preparedSenderUpdatedAt};return v(a),g("The queued email is paused for review. It cannot auto-send while you edit this email."),await p(),a}catch(i){return l(i.message),null}finally{u(!1)}},Ie=async()=>{if(!s)return;g(null),l(null),E(!1);const t=await Ne(s);t&&(fe(z(t.intendedToJson?.slice(1))),be(z(t.intendedCcJson)),je(z(t.intendedBccJson)),Ue(t.workflowType==="post_recording"?"[email protected]":t.replyTo||""),T(!0))},Oe=async()=>{if(!s)return;g(null),l(null),T(!1);const t=await Ne(s);if(!t)return;const i=t.subject||"";H(i),W(ce),pe(i),xe(ce),E(!0)},ye=()=>{K&&!window.confirm("Discard unsaved subject and message changes?")||E(!1)},Ce=()=>{window.confirm("Discard unsaved recipient changes? No saved recipients will change.")&&T(!1)},He=()=>{$&&!window.confirm("Discard unsaved recipient changes? No saved recipients will change.")||S&&K&&!window.confirm("Discard unsaved subject and message changes?")||(++d.current,T(!1),E(!1),v(null))},We=async()=>{if(!s)return;const t=s.intendedToJson?.[0];if(!t){l("This run has no primary guest recipient.");return}let i,a,b;try{i=Z(he,"Additional To"),a=Z(ge,"CC"),b=Z(we,"BCC")}catch(m){l(m.message);return}u(!0),l(null);try{const m=await x(`/runs/${s.id}/envelope`,c,{method:"PATCH",body:{confirm:!0,expectedUpdatedAt:s.updatedAt,to:[t,...i],cc:a,bcc:b,replyTo:ve.trim()||null}});T(!1),await G(m.run.id),g("Recipients saved. The email remains paused until you review the complete envelope and explicitly approve it to run."),await p()}catch(m){l(m.message)}u(!1)},Ke=async()=>{if(!s)return;const t=R.trim(),i=A.trim();if(!t||t.length>300){l("Subject is required and must be 300 characters or less.");return}if(!i||i.length>1e5){l("Message is required and must be under 100,000 characters.");return}if(!s.preparedSenderUpdatedAt){l("Reload this run so its current sender signature can be verified.");return}u(!0),l(null);try{const a=await x(`/runs/${s.id}/content`,c,{method:"PATCH",body:{confirm:!0,expectedUpdatedAt:s.updatedAt,expectedSenderUpdatedAt:s.preparedSenderUpdatedAt,subject:t,messageText:i}});v(a.run),D(a.previewHtml),J(a.editableMessageText),L(a.contentEditable),I(a.contentEditBlockReason),H(a.run.subject||t),W(a.editableMessageText),pe(a.run.subject||t),xe(a.editableMessageText),E(!1),g(a.changed?"Message saved. This email remains paused until you review the rendered email and recipients, then explicitly approve it to run.":"No message changes were needed."),await p()}catch(a){l(a.message)}u(!1)},ke=t=>n?window.confirm(n.testMode?`${t} in TEST MODE? The provider will send only to ${n.testRecipient}; the real guest recipients will remain in the audit record.`:`${t} in LIVE MODE? This will email the intended To, CC, and BCC recipients shown on this run.`):!1,Ve=async()=>{if(!(!s||!n||!ke("Run this email now"))){u(!0),l(null),g(null);try{const t=await x(`/runs/${s.id}/run-now`,c,{method:"POST",body:{confirm:!0,expectedUpdatedAt:s.updatedAt,expectedTestMode:n.testMode}});await G(t.run.id),await p(),["sent","test_sent"].includes(t.run.status)?g(t.run.status==="test_sent"?`Test email sent to ${n.testRecipient}.`:"Email sent to the intended recipients."):t.run.errorMessage||l(`The send was not completed (current status: ${t.run.status}).`)}catch(t){l(t.message)}u(!1)}},Ge=async()=>{if(!(!s||!n||!ke("Approve and run this reviewed email now"))){u(!0),l(null),g(null);try{const t=await x(`/runs/${s.id}/approve-and-run`,c,{method:"POST",body:{confirm:!0,expectedUpdatedAt:s.updatedAt,expectedTestMode:n.testMode}});await G(t.run.id),await p(),["sent","test_sent"].includes(t.run.status)?g(t.run.status==="test_sent"?`Reviewed test email sent to ${n.testRecipient}.`:"Reviewed email sent to the intended recipients."):t.run.errorMessage||l(`The send was not completed (current status: ${t.run.status}).`)}catch(t){l(t.message)}u(!1)}},Te=async t=>{if(!s||s.status!=="manual_review")return;const i=window.prompt("Paste the provider-history evidence you checked (message ID, log result, or concise verification note):");if(!(!i?.trim()||!window.confirm(t==="delivered"?"Confirm the provider shows this email was delivered? This will record the run as sent.":"Confirm the provider shows this email was NOT delivered? This will make a reviewed replacement eligible."))){u(!0),l(null);try{const b=await x(`/runs/${s.id}/resolve-delivery`,c,{method:"POST",body:{confirm:!0,outcome:t,evidence:i.trim()}});await V(b.run.id),await p()}catch(b){l(b.message)}u(!1)}};if(s){const t=$||S,i=["queued","needs_review","awaiting_approval","ready"].includes(s.status),a=s.workflowType!=="internal_completion"&&["sent","failed","
2skipped","cancelled"].includes(s.status),b=s.workflowType!=="internal_completion"&&i&&s.intendedToJson.length>0&&!s.sentAt&&!s.providerMessageId&&s.actualToJson==null&&s.actualCcJson==null&&s.actualBccJson==null,m=["guest_prep","post_recording"].includes(s.workflowType)&&i&&!s.sentAt&&!s.providerMessageId&&s.actualToJson==null&&s.actualCcJson==null&&s.actualBccJson==null,O=m&&ue&&!!s.preparedSenderUpdatedAt,Ye=!["episode_live","internal_completion"].includes(s.workflowType)&&["needs_review","awaiting_approval","ready"].includes(s.status),Se=s.scheduledFor?new Date(s.scheduledFor).getTime():null,_=s.status==="queued"&&Se!==null&&Se<=Date.now(),Qe=()=>{U(globalThis.crypto.randomUUID()),P(!0)};return e.jsxs("div",{children:[e.jsxs("button",{className:`${f} mb-4`,onClick:He,"data-testid":"button-back-to-runs",children:[e.jsx(tt,{className:"w-4 h-4"})," All runs"]}),Be?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-8",children:[e.jsx(k,{className:"w-4 h-4 animate-spin"})," Loading…"]}):e.jsxs(ze,{children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-3 justify-between mb-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[e.jsx(Ee,{status:s.status}),Me(s)&&e.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wide px-2 py-0.5 rounded-full",style:{backgroundColor:"#FFF3D6",color:"#8B6914"},children:"test mode"})]}),e.jsx("h3",{className:"text-lg font-bold",style:{color:w},children:s.subject||"(no subject)"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Run #",s.id," · ",Y(s.workflowType)," · trigger ",s.triggerType," · created"," ",B(s.createdAt)]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[O&&!t&&e.jsxs("button",{className:f,onClick:()=>{Oe()},disabled:o,"data-testid":"button-edit-run-content",children:[e.jsx(st,{className:"w-4 h-4"})," Edit message"]}),b&&!t&&e.jsxs("button",{className:f,onClick:()=>{Ie()},disabled:o,"data-testid":"button-edit-run-recipients",children:[e.jsx(at,{className:"w-4 h-4"})," Edit recipients"]}),s.status==="queued"&&!t&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:y,style:{backgroundColor:w},onClick:()=>{Ve()},disabled:o||!n,title:n?void 0:"Delivery settings must load before sending","data-testid":"button-run-now",children:[o?e.jsx(k,{className:"w-4 h-4 animate-spin"}):e.jsx(Q,{className:"w-4 h-4"}),"Run now"]}),e.jsxs("button",{className:f,onClick:Le,disabled:o,"data-testid":"button-cancel-run",children:[e.jsx(Ae,{className:"w-4 h-4"})," Cancel"]})]}),Ye&&!t&&e.jsxs("button",{className:y,style:{backgroundColor:w},onClick:()=>{Ge()},disabled:o||!n,"data-testid":"button-approve-and-run",children:[o?e.jsx(k,{className:"w-4 h-4 animate-spin"}):e.jsx(Q,{className:"w-4 h-4"}),"Approve & run now"]}),!t&&a&&qe?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs font-bold",style:{color:C},children:"Send this email again?"}),e.jsxs("button",{className:y,style:{backgroundColor:C},onClick:Je,disabled:o,"data-testid":"button-confirm-resend",children:[o&&e.jsx(k,{className:"w-4 h-4 animate-spin"})," ","Yes, resend"]}),e.jsx("button",{className:f,onClick:()=>{P(!1),U(null)},"data-testid":"button-cancel-resend",children:"No"})]}):!t&&a?e.jsxs("button",{className:y,style:{backgroundColor:w},onClick:Qe,"data-testid":"button-resend-run",children:[e.jsx(Q,{className:"w-4 h-4"})," Resend…"]}):null]})]}),oe?e.jsx("div",{className:"rounded-xl border p-3 mb-4 text-sm",style:{borderColor:"#B8D7CC",backgroundColor:"#F2FAF7",color:"#285B53"},role:"status","data-testid":"notice-run-action",children:oe}):null,s.status==="queued"?e.jsxs("div",{className:"rounded-xl border p-3 mb-4 text-sm flex items-start gap-2",style:{borderColor:_?"#E4C374":"#BCD0E1",backgroundColor:_?"#FFF9E9":"#F4F8FB",color:_?"#76510A":w},children:[_?e.jsx(X,{className:"w-4 h-4 mt-0.5 shrink-0"}):e.jsx(Fe,{className:"w-4 h-4 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold",children:_?"This email is overdue in the queue":s.scheduledFor?`Scheduled for ${B(s.scheduledFor)}`:"Queued for the next background check"}),e.jsxs("p",{className:"mt-1",children:["The queue refreshes automatically. Use"," ",e.jsx("strong",{children:"Run now"})," to recover a missed job or intentionally send before its scheduled time."]})]})]}):null,["needs_review","awaiting_approval","ready"].includes(s.status)?e.jsxs("div",{className:"rounded-xl border border-border bg-[#FAFAF8] p-3 mb-4 text-sm","data-testid":"notice-run-review-required",children:[e.jsx("p",{className:"font-bold",style:{color:w},children:s.status==="ready"?"Reviewed and ready":"Review required — this email will not auto-send"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:s.workflowType==="episode_live"?"Use Guest workspaces to finish the tailored Episode Live review and send it. Recipient edits made here clear any prior approval.":"Use Edit message or Edit recipients if needed, review the complete email, then use Ap
2prove & run now. Test Mode still redirects actual delivery to the fixed test inbox."})]}):null,m&&!ue&&me?e.jsxs("div",{className:"rounded-xl border p-3 mb-4 text-sm flex items-start gap-2",style:{borderColor:"#E4C374",backgroundColor:"#FFF9E9",color:"#76510A"},role:"alert","data-testid":"notice-run-content-edit-blocked",children:[e.jsx(X,{className:"w-4 h-4 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold",children:"Message editing needs attention"}),e.jsx("p",{className:"mt-1",children:me})]})]}):null,S?e.jsxs("div",{className:"rounded-xl border p-4 mb-4",style:{borderColor:"#BCD0E1",backgroundColor:"#F7FAFC"},"data-testid":"editor-run-content",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-bold",style:{color:w},children:"Edit message for this guest"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"This changes only this prepared email—not the reusable workflow template. The approved sender signature is added automatically when you save."})]}),e.jsx("button",{className:f,onClick:ye,disabled:o,"data-testid":"button-close-content-editor",children:"Close"})]}),e.jsxs("label",{className:"block mb-4",children:[e.jsx("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Subject"}),e.jsx("input",{className:`${j} mt-1`,value:R,onChange:h=>H(h.target.value),maxLength:300,"data-testid":"input-run-subject"}),e.jsxs("span",{className:"block text-right text-[11px] text-muted-foreground mt-1",children:[R.length,"/300"]})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Message"}),e.jsx("textarea",{className:`${j} mt-1 min-h-[420px] font-sans leading-relaxed`,value:A,onChange:h=>W(h.target.value),maxLength:1e5,"data-testid":"textarea-run-message"}),e.jsxs("span",{className:"block text-right text-[11px] text-muted-foreground mt-1",children:[A.length.toLocaleString(),"/100,000"]})]}),n?.testMode?e.jsxs("p",{className:"text-xs mt-3",style:{color:"#8B6914"},children:["Test Mode is on. Saving does not send; a later approved run will deliver only to ",n.testRecipient,"."]}):null,s.workflowType==="post_recording"?e.jsx("p",{className:"text-xs mt-2 text-muted-foreground",children:"Replies are locked to [email protected] for this post-recording email."}):null,e.jsxs("div",{className:"flex flex-wrap gap-2 mt-4",children:[e.jsxs("button",{className:y,style:{backgroundColor:w},onClick:()=>{Ke()},disabled:o||!K||!R.trim()||R.trim().length>300||!A.trim()||A.length>1e5,"data-testid":"button-save-run-content",children:[o&&e.jsx(k,{className:"w-4 h-4 animate-spin"}),"Save message"]}),e.jsx("button",{className:f,onClick:ye,disabled:o,children:"Discard changes"})]})]}):null,$?e.jsxs("div",{className:"rounded-xl border p-4 mb-4",style:{borderColor:"#BCD0E1",backgroundColor:"#F7FAFC"},"data-testid":"editor-run-recipients",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-bold",style:{color:w},children:"Edit recipients for this email"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Enter one person per line as [email protected] or Name <[email protected]>. This changes this prepared email, not the workflow defaults."})]}),e.jsx("button",{className:f,onClick:Ce,disabled:o,"data-testid":"button-close-recipient-editor",children:"Close"})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Primary guest (kept in To)"}),e.jsx("input",{className:`${j} mt-1 bg-[#F0F0EC]`,value:$e(s.intendedToJson[0]),disabled:!0,"data-testid":"input-primary-recipient"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Reply-to (workflow controlled)"}),e.jsx("input",{className:`${j} mt-1`,value:ve,disabled:!0,title:"Reply routing is controlled by the approved workflow","data-testid":"input-run-reply-to"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Additional To"}),e.jsx("textarea",{className:`${j}
2 mt-1 min-h-24`,value:he,onChange:h=>fe(h.target.value),placeholder:"One person per line","data-testid":"textarea-run-additional-to"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"CC"}),e.jsx("textarea",{className:`${j} mt-1 min-h-24`,value:ge,onChange:h=>be(h.target.value),placeholder:"One person per line","data-testid":"textarea-run-cc"})]}),e.jsxs("label",{className:"block md:col-span-2",children:[e.jsx("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"BCC"}),e.jsx("textarea",{className:`${j} mt-1 min-h-20`,value:we,onChange:h=>je(h.target.value),placeholder:"One person per line","data-testid":"textarea-run-bcc"})]})]}),n?.testMode?e.jsxs("p",{className:"text-xs mt-3",style:{color:"#8B6914"},children:["Test Mode is on: these intended recipients will be saved, but actual delivery goes only to ",n.testRecipient,"."]}):null,["ready","awaiting_approval"].includes(s.status)?e.jsx("p",{className:"text-xs mt-2",style:{color:C},children:"Saving recipient changes clears the existing approval so the complete envelope can be reviewed again."}):null,e.jsxs("div",{className:"flex flex-wrap gap-2 mt-4",children:[e.jsxs("button",{className:y,style:{backgroundColor:w},onClick:()=>{We()},disabled:o,"data-testid":"button-save-run-recipients",children:[o&&e.jsx(k,{className:"w-4 h-4 animate-spin"}),"Save recipients"]}),e.jsx("button",{className:f,onClick:Ce,disabled:o,children:"Cancel"})]})]}):null,s.status==="manual_review"?e.jsxs("div",{className:"rounded-xl border p-3 mb-4 text-sm flex items-start gap-2",style:{borderColor:"#E8A6A6",backgroundColor:"#FFF3F3",color:C},role:"alert",children:[e.jsx(X,{className:"w-4 h-4 mt-0.5 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-bold",children:"Verify delivery before any resend"}),e.jsxs("p",{className:"mt-1",children:[s.errorMessage||"The provider may have accepted this email. Check provider history before creating a replacement send.",s.providerMessageId?` Provider message: ${s.providerMessageId}.`:""]}),e.jsxs("div",{className:"flex flex-wrap gap-2 mt-3",children:[e.jsxs("button",{className:y,style:{backgroundColor:"#285B53"},onClick:()=>{Te("delivered")},disabled:o,"data-testid":"button-resolve-delivered",children:[e.jsx(nt,{className:"w-4 h-4"})," Provider confirms delivered"]}),e.jsxs("button",{className:f,style:{borderColor:C,color:C},onClick:()=>{Te("not_delivered")},disabled:o,"data-testid":"button-resolve-not-delivered",children:[e.jsx(Ae,{className:"w-4 h-4"})," Confirm not delivered"]})]})]})]}):null,e.jsxs("div",{className:"space-y-3 border-t border-border pt-4 mb-4",children:[e.jsx(ee,{label:"To",intended:s.intendedToJson,actual:s.actualToJson}),e.jsx(ee,{label:"CC",intended:s.intendedCcJson,actual:s.actualCcJson}),e.jsx(ee,{label:"BCC",intended:s.intendedBccJson,actual:s.actualBccJson}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-2 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Sender"}),e.jsx("p",{children:s.senderEmail||s.preparedSenderEmail||"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Provider / message id"}),e.jsxs("p",{className:"break-all",children:[s.provider||"—",s.providerMessageId?` · ${s.providerMessageId}`:""]})]}),s.replyTo&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Reply-to"}),e.jsx("p",{children:s.replyTo})]}),s.sentAt&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Sent at"}),e.jsx("p",{children:B(s.sentAt)})]}),s.scheduledFor&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Scheduled for"}),e.jsx("p",{children:B(s.scheduledFor)})]}),s.approvedBy&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Approved by"}),e.jsx("p",{children:s.approvedBy})]})]}),s.errorMessage&&e.jsxs("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"#FBDCDC",backgroundColor:"#FFF7F7",color:C},"data-testid":"text-run-error",children:[e.jsx("p",{className:"font-bold",children:"Why the last attempt stopped"}),e.jsx("p",{className:"mt-1",children:s.errorMessage})]})]}),e.jsx(Re,{message:ae}),S?null:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("p",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Email body"}),e.jsx("button",{className:"text-xs underline text-muted-foreground hover:text-foreground",onClick:()=>de(h=>!h),"data-testid":"button-toggle-plaintext",children:ie?"show HTML":"show plaintext"})]}),ie?e.jsx("pre",{className:"text-xs whitespace-pre-wrap bg-[#FAFAF8] border border-border rounded-lg p-4 max-h-[480px] overflow-auto","data-testid":"text-run-plaintext",children:s.plaintextBody||"—"}):ne?e.jsx(Ze,{html:ne,title:`Run ${s.id}`,minHeight:480}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No HTML body stored."})]})]})]})}return e.jsxs("div",{children:[e.jsx(et,{title:"Communication runs",subtitle:"Every send attempt — intended vs actual recipients, status, and provider receipts.",right:e.jsxs("button",{className:f,onClick:()=>p(),"data-testid":"button-refresh-runs",children:[e.jsx(Fe,{className:"w-4 h-4"})," Refresh"]})}),e.jsx(Re,{message:ae}),e.jsxs("div",{className:"flex flex-wrap gap-3 mb-4",children:[e.jsxs("select",{className:`${j} !w-auto`,value:N,onChange:t=>se(t.target.value),"data-testid":"select-filter-status",children:[e.jsx("option",{value:"",children:"All statuses"}),rt.map(t=>e.jsx("option",{value:t,children:t.replace(/_/g," ")},t))]}),e.jsxs("select",{className:`${j} !w-auto`,value:q,onChange:t=>_e(t.target.value),"data-testid":"select-filter-workflow",children:[e.jsx("option",{value:"",children:"All workflows"}),lt.map(t=>e.jsx("option",{value:t,children:Y(t)},t))]})]}),F?F.length===0?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["No runs yet. Use ",e.jsx("strong",{children:"Send Test"})," from a template to create the first one."]}):e.jsx("div",{className:"bg-white rounded-2xl border border-border overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[#FAFAF8] text-left text-xs uppercase tracking-wider text-muted-foreground",children:[e.jsx("th",{className:"px-4 py-3 font-bold",children:"Status"}),e.jsx("th",{className:"px-4 py-3 font-bold",children:"Subject"}),e.jsx("th",{className:"px-4 py-3 font-bold",children:"Workflow"}),e.jsx("th",{className:"px-4 py-3 font-bold",children:"Intended to"}),e.jsx("th",{className:"px-4 py-3 font-bold",children:"Created"})]})}),e.jsx("tbody",{className:"divide-y divide-border",children:F.map(t=>e.jsxs("tr",{className:"hover:bg-[#FAFAF8] cursor-pointer",onClick:()=>V(t.id),"data-testid":`row-run-${t.id}`,children:[e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ee,{status:t.status}),Me(t)&&e.jsx("span",{className:"text-[10px] font-bold uppercase text-muted-foreground",children:"test"})]})}),e.jsx("td",{className:"px-4 py-3 font-medium max-w-[320px] truncate",children:t.subject||"(no subject)"}),e.jsx("td",{className:"px-4 py-3 text-muted-foreground whitespace-nowrap",children:Y(t.workflowType)}),e.jsx("td",{className:"px-4 py-3 text-muted-foreground max-w-[240px] truncate",children:te(t.intendedToJson)}),e.jsx("td",{className:"px-4 py-3 text-muted-foreground whitespace-nowrap",children:B(t.createdAt)})]},t.id))})]})})}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-8",children:[e.jsx(k,{className:"w-4 h-4 animate-spin"})," Loading…"]})]})}export{Rt 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.