PageSourceSearch

https://tadlo.ai/static/js/3042.ea8d93fd.chunk.js

js tadlo.ai collected 2026-10-05 14:37:49 UTC 33,636 bytes, 3 lines download raw bytes

1/*! For license information please see 3042.ea8d93fd.chunk.js.LICENSE.txt */
2"use strict";(globalThis.webpackChunkfrontend=globalThis.webpackChunkfrontend||[]).push([[3042],{43042(e,t,a){a.r(t),a.d(t,{default:()=>L,freshnessLabel:()=>_,keptLabel:()=>A,retentionNote:()=>$});var s=a(65043),r=a(76833),d=a(75088),o=a(77819);const l=(0,a(77784).A)("ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);var n=a(78231),i=a(40614),c=a(22024),x=a(39292),m=a(37719),b=a(94805),u=a(30086),p=a(50516),v=a(28646),h=a(35087),g=a(93359),y=a(46492),f=a(27816),j=a(70579);const w=e=>{if(!e)return"\u2014";try{return new Date(e).toLocaleString("en-IN",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}catch{return e}};function N(e){let{status:t,receivedAt:a}=e;const s="pending"===t&&((n=a)?(Date.now()-new Date(n).getTime())/6e4:0)>5;var n;const i={processed:{bg:"bg-teal-500/15",text:"text-teal-600 dark:text-teal-300",border:"border-teal-500/30",icon:r.A},pending:{bg:"bg-amber-500/15",text:"text-amber-600 dark:text-amber-300",border:"border-amber-500/30",icon:d.A},failed:{bg:"bg-red-500/15",text:"text-red-600 dark:text-red-300",border:"border-red-500/30",icon:o.A},wont_fix:{bg:"bg-gray-500/15",text:"text-gray-600 dark:text-gray-300",border:"border-gray-500/30",icon:l}},c=i[t]||i.pending,x=c.icon,m="wont_fix"===t?"Won't Fix":t;return(0,j.jsxs)("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[11px] font-semibold border ${c.bg} ${c.text} ${c.border} ${s?"animate-pulse":""}`,"data-testid":`webhook-status-pill-${t}`,children:[(0,j.jsx)(x,{className:"w-3 h-3"}),m]})}function k(e){const t=null===e||void 0===e?void 0:e.retention_days;if(!t||null===e||void 0===e||!e.retained_since)return!1;return(Date.now()-new Date(e.retained_since).getTime())/864e5<=t+1}function _(e){const t=null===e||void 0===e?void 0:e.stats_age_seconds;if(null===t||void 0===t)return"at an unknown time";if(t<90)return"just now";const a=Math.round(t/60);if(a<60)return`${a} min ago`;const s=Math.round(a/60);return 1===s?"1 hour ago":`${s} hours ago`}function A(e,t){return k(t)?`${e} \xb7 last ${t.retention_days} days`:`${e} \xb7 kept`}function $(e){if(!e)return"";const t=e.retention_days||14,a=e.retained_since;if(!a)return`Webhook history is kept for ${t} days; older events are deleted hourly.`;const s=new Date(a).toLocaleDateString("en-IN",{day:"numeric",month:"short",year:"numeric"});return k(e)?`Webhook history is kept for ${t} days; older events are deleted hourly. Oldest event held: ${s}.`:`Webhook history is kept for ${t} days and older events are deleted hourly \u2014 the cleanup has not caught up yet, so these counts still reach back to ${s}.`}function S(e){let{label:t,value:a,tone:s,testId:r}=e;const d={neutral:"border-[var(--border)] bg-[var(--bg-elevated)]",teal:"border-teal-500/30 bg-teal-500/5",amber:"border-amber-500/30 bg-amber-500/5",red:"border-red-500/30 bg-red-500/5"};return(0,j.jsxs)("div",{className:`rounded-xl border p-4 ${d[s]||d.neutral}`,"data-testid":r,children:[(0,j.jsx)("div",{className:"text-[11px] uppercase tracking-wide text-[var(--text-secondary)] font-semibold",children:t}),(0,j.jsx)("div",{className:"mt-1.5 text-2xl font-bold text-[var(--text-primary)]",children:null!==a&&void 0!==a?a:"\u2014"})]})}function C(e){var t;let{id:a,onClose:r}=e;
2const[d,o]=(0,s.useState)(null),[l,x]=(0,s.useState)("");return(0,s.useEffect)(()=>{a&&g.F.get(`/webhooks/${encodeURIComponent(a)}`).then(o).catch(e=>x((0,g.c)(e)))},[a]),a?(0,j.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50",onClick:r,"data-testid":"webhook-detail-modal",children:(0,j.jsxs)("div",{className:"bg-[var(--bg-surface)] border border-[var(--border)] rounded-xl shadow-xl max-w-3xl w-full max-h-[85vh] overflow-hidden flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,j.jsxs)("div",{className:"flex items-center justify-between px-5 py-3 border-b border-[var(--border)]",children:[(0,j.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,j.jsx)(n.A,{className:"w-4 h-4 text-[var(--accent)]"}),(0,j.jsx)("span",{className:"text-sm font-semibold truncate",children:"Webhook event detail"})]}),(0,j.jsx)("button",{onClick:r,className:"p-1 rounded hover:bg-[var(--bg-elevated)]","data-testid":"webhook-detail-close",children:(0,j.jsx)(i.A,{className:"w-4 h-4"})})]}),(0,j.jsxs)("div",{className:"flex-1 overflow-y-auto p-5 space-y-4",children:[l&&(0,j.jsx)("div",{className:"text-sm text-red-500","data-testid":"webhook-detail-error",children:l}),!d&&!l&&(0,j.jsxs)("div",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)]",children:[(0,j.jsx)(c.A,{className:"w-4 h-4 animate-spin"})," Loading\u2026"]}),d&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)("div",{className:"grid grid-cols-2 gap-3 text-[12px]",children:[(0,j.jsx)(I,{label:"ID",value:d.idempotency_key,mono:!0}),(0,j.jsx)(I,{label:"Status",value:(0,j.jsx)(N,{status:d.status,receivedAt:d.received_at})}),(0,j.jsx)(I,{label:"Event type",value:d.event_type}),(0,j.jsx)(I,{label:"Signature",value:d.signature_status}),(0,j.jsx)(I,{label:"Received",value:w(d.received_at)}),(0,j.jsx)(I,{label:"Processed",value:w(d.processed_at)}),(0,j.jsx)(I,{label:"Failed",value:w(d.failed_at)}),(0,j.jsx)(I,{label:"Attempts",value:String(null!==(t=d.attempts)&&void 0!==t?t:0)})]}),d.error&&(0,j.jsxs)("div",{className:"rounded-lg border border-red-500/30 bg-red-500/5 p-3",children:[(0,j.jsx)("div",{className:"text-[11px] uppercase font-semibold text-red-600 dark:text-red-300 mb-1.5",children:"Error"}),(0,j.jsx)("pre",{className:"text-[12px] text-red-700 dark:text-red-200 whitespace-pre-wrap break-words font-mono","data-testid":"webhook-detail-error-text",children:d.error})]}),(0,j.jsxs)("div",{children:[(0,j.jsx)("div",{className:"text-[11px] uppercase font-semibold text-[var(--text-secondary)] mb-1.5",children:"Raw payload"}),(0,j.jsx)("pre",{className:"text-[11.5px] leading-snug bg-[var(--bg-elevated)] border border-[var(--border)] rounded-lg p-3 overflow-auto font-mono max-h-80","data-testid":"webhook-detail-payload",children:JSON.stringify(d.raw_payload,null,2)})]})]})]})]})}):null}function I(e){let{label:t,value:a,mono:s}=e;return(0,j.jsxs)("div",{children:[(0,j.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[var(--text-secondary)] font-semibold",children:t}),(0,j.jsx)("div",{className:"mt-0.5 text-[var(--text-primary)] "+(s?"font-mono break-all":""),children:a||"\u2014"})]})}function R(){var e,t,a,r,d,o,l,n,i,m,b;const[u,p]=(0,s.useState)(""),[v,h]=(0,s.useState)(null),[f,w]=(0,s.useState)(!1),[k,_]=(0,s.useState)(""),A=async e=>{if(null===e||void 0===e||e.preventDefault(),u.trim()){w(!0),_(""),h(null);try{const e=await g.F.get(`/webhooks/${encodeURIComponent(u.trim())}/debug`);h(e)}catch(t){_((0,g.c)(t))}finally{w(!1)}}};return(0,j.jsxs)("div",{className:"rounded-xl border border-[var(--border)] bg-[var(--bg-surface)] p-4 mb-6","data-testid":"webhook-debug-section",children:[(0,j.jsx)("div",{className:"flex items-center justify-between gap-3 mb-3",children:(0,j.jsxs)("div",{children:[(0,j.jsxs)("h2",{className:"text-sm font-semibold flex items-center gap-1.5",children:[(0,j.jsx)(x.A,{className:"w-4 h-4 text-[var(--accent)]"}),"Debug Delivery"]}),(0,j.jsx)("p",{className:"text-xs text-[var(--text-secondary)] mt-0.5",children:"Paste an idempotency key to see the full processing chain \u2014 exactly where the delivery broke."})]})}),(0,j.jsxs)("form",{onSubmit:A,className:"flex gap-2",children:[(0,j.jsx)("input",{type:"text",placeholder:"e.g. 27238198739098946:1714000000:comments:",className:"flex-1 px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--bg-surface)] text-sm font-mono",value:u,onChange:e=>p(e.target.value),"data-testid":"webhook-debug-input"}),(0,j.jsxs)("button",{type:"submit",disabled:f||!u.trim(),className:"px-4 py-2 rounded-lg bg-[var(--accent)] text-white text-sm font-semibold hover:opacity-90 disabled:opacity-60 inline-flex items-center gap-1.5","data-testid":"webhook-debug-submit",children:[f?(0,j.jsx)(c.A,{className:"w-4 h-4 animate-spin"}):(0,j.jsx)(x.A,{className:"w-4 h-4"}),"Debug"]})]}
2),k&&(0,j.jsx)("div",{className:"mt-3 px-3 py-2 rounded-lg border border-red-500/30 bg-red-500/5 text-red-600 dark:text-red-300 text-sm","data-testid":"webhook-debug-error",children:k}),v&&(0,j.jsxs)("div",{className:"mt-4 space-y-4","data-testid":"webhook-debug-result",children:[(0,j.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-3 text-[12px] pb-3 border-b border-[var(--border)]",children:[(0,j.jsx)(I,{label:"Status",value:(0,j.jsx)(N,{status:null===(e=v.webhook_event)||void 0===e?void 0:e.status,receivedAt:null===(t=v.webhook_event)||void 0===t?void 0:t.received_at})}),(0,j.jsx)(I,{label:"Event",value:(0,j.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-[11px] font-medium bg-[var(--bg-secondary)] border border-[var(--border)]","data-testid":"webhook-debug-event-kind",children:(null===(a=v.extracted)||void 0===a?void 0:a.event_kind)||"unknown"})}),(0,j.jsx)(I,{label:"Attempts",value:String(null!==(r=null===(d=v.webhook_event)||void 0===d?void 0:d.attempts)&&void 0!==r?r:0)}),(0,j.jsx)(I,{label:"Signature",value:null===(o=v.webhook_event)||void 0===o?void 0:o.signature_status}),(0,j.jsx)(I,{label:"Flow matched",value:(null===(l=v.extracted)||void 0===l?void 0:l.flow_matched)||"\u2014"})]}),(0,j.jsxs)("div",{className:"relative pl-7",children:[(0,j.jsx)("div",{className:"absolute left-3 top-1 bottom-1 w-px bg-[var(--border)]"}),v.processing_steps.map((e,t)=>(0,j.jsx)(D,{step:e},t))]}),(0,j.jsxs)("details",{className:"rounded-lg border border-[var(--border)] p-3","data-testid":"webhook-debug-queue-items",open:!0,children:[(0,j.jsxs)("summary",{className:"text-xs font-semibold cursor-pointer",children:["Queue items (",(null===(n=v.queue_items)||void 0===n?void 0:n.length)||0,")"]}),(null===(i=v.queue_items)||void 0===i?void 0:i.length)>0?(0,j.jsx)("div",{className:"mt-2 space-y-2",children:v.queue_items.map(e=>(0,j.jsx)(q,{item:e,onResetRetry:()=>(async e=>{if(e){if(window.confirm("Reset & Retry this automation?\n\nClears dedup history and re-queues all cancelled items so you can re-test the flow without waiting 24h."))try{const t=await g.F.post(`/automations/${e}/reset-states`);y.oR.success("Reset complete",`${t.queue_items_requeued||0} items requeued`),A()}catch(t){y.oR.error("Reset failed",(0,g.c)(t))}}else y.oR.error("No automation_id on this queue item")})(e.automation_id)},e.id))}):(0,j.jsx)("div",{className:"mt-2 text-xs text-[var(--text-secondary)]",children:"No queue items found for this webhook."})]}),(0,j.jsxs)("details",{className:"rounded-lg border border-[var(--border)] p-3","data-testid":"webhook-debug-send-logs",open:!0,children:[(0,j.jsxs)("summary",{className:"text-xs font-semibold cursor-pointer",children:["Send logs (",(null===(m=v.send_logs)||void 0===m?void 0:m.length)||0,")"]}),(null===(b=v.send_logs)||void 0===b?void 0:b.length)>0?(0,j.jsx)("div",{className:"mt-2 space-y-2",children:v.send_logs.map((e,t)=>(0,j.jsx)(P,{log:e},`${e.queue_item_id}-${t}`))}):(0,j.jsx)("div",{className:"mt-2 text-xs text-[var(--text-secondary)]",children:"No send logs \u2014 DM was never dispatched."})]}),(0,j.jsxs)("details",{className:"rounded-lg border border-[var(--border)] p-3",children:[(0,j.jsx)("summary",{className:"text-xs font-semibold cursor-pointer",children:"Raw payload"}),(0,j.jsx)("pre",{className:"mt-2 text-[11px] font-mono bg-[var(--bg-elevated)] rounded p-2 overflow-auto max-h-60",children:JSON.stringify(v.raw_payload,null,2)})]})]})]})}function D(e){let{step:t}=e;const a={success:{Icon:r.A,color:"text-teal-500",bg:"bg-teal-500/10 border-teal-500/30"},failed:{Icon:o.A,color:"text-red-500",bg:"bg-red-500/10 border-red-500/30"},warn:{Icon:m.A,color:"text-amber-500",bg:"bg-amber-500/10 border-amber-500/30"},pending:{Icon:d.A,color:"text-[var(--text-secondary)]",bg:"bg-[var(--bg-elevated)] border-[var(--border)]"}},s=a[t.status]||a.pending,l=s.Icon,n=t.timestamp?new Date(t.timestamp).toLocaleString("en-IN",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}):"\u2014";return(0,j.jsxs)("div",{className:"relative pb-4 last:pb-0","data-testid":`debug-step-${t.step}-${t.status}`,children:[(0,j.jsx)("div",{className:`absolute -left-7 top-0 w-6 h-6 rounded-full border flex items-center justify-center ${s.bg}`,children:(0,j.jsx)(l,{className:`w-3.5 h-3.5 ${s.color}`})}),(0,j.jsx)("div",{className:"text-sm font-semibold capitalize",children:t.step.replaceAll("_"," ")}),(0,j.jsx)("div",{className:"text-xs "+("failed"===t.status?"text-red-500":"text-[var(--text-secondary)]"),children:t.detail}),(0,j.jsx)("div",{className:"text-[10px] text-[var(--text-secondary)] font-mono mt-0.5",children:n})]})}const M={"dedup_block:per_user_cap_reached":{icon:m.A,color:"text-amber-600",bg:"bg-amber-500/10 border-amber-500/30",label:"Cancelled \u2014 same user already received a DM in the last 24h (per-user limit reached)"},dedup_block:{icon:m.A,color:"text-amber-600",bg:"bg-amber-500/10 border-amber-500/30",label:"Cancelled \u2014 duplicate trigger suppressed"},account_disconnected:{icon:o.A,color:"text-red-600",bg:"bg-red-500/10 border-red-500/30",label:"Cancelled \u2014 Instagram account disconnected"},no_ig_account:{icon:o.A,color:"text-red-600",bg:"bg-red-500/10 border-red-500/30",label:"Cancelled \u2014 no Instagram account row found"},no_access_token:{icon:o.A,color:"text-red-600",bg:"bg-red-500/10 border-red-500/30",label:"Cancelled \u2014 Instagram access token missing"},ig_token_invalid:{icon:o.A,color:"text-red-600",bg:"bg-red-500/10 border-red-500/30",label:"Failed \u2014 Instagram token expired (user must reconnect)"}};function q(e){var t;let{item:a,onResetRetry:s}=e;const r=a.status||"unknown",d=a.failure_reason,l="cancelled"===r||"failed"===r,n=l?function(e){return e?M[e]?M[e]:e.startsWith("dedup_block:")?M.dedup_block:{icon:o.A,color:"text-red-600",bg:"bg-red-500/10 border-red-500/30",label:`Failed \u2014 ${e}`}:null}(d):null,i=null===n||void 0===n?void 0:n.icon,c="permanent"===a.failure_policy,x=l&&!c&&!!a.automation_id,m="sent"===r?"bg-teal-500/10 border-teal-500/30 text-teal-600":"queued"===r?"bg-blue-500/10 border-blue-500/30 text-blue-600":"processing"===r?"bg-amber-500/10 border-amber-500/30 text-amber-600":"expired"===r?"bg-zinc-500/10 border-zinc-500/30 text-zinc-600":"bg-red-500/10 border-red-500/30 text-red-600";return(0,j.jsxs)("div",{className:"rounded-md border border-[var(--border)] p-2 bg-[var(--bg-elevated)]","data-testid":`debug-queue-item-${a.id}`,children:[(0,j.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,j.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,j.jsx)("span",{className:`px-2 py-0.5 rounded text-[11px] font-semibold border ${m}`,children:r}),(0,j.jsx)("span",{className:"text-xs font-mono text-[var(--text-secondary)] truncate",children:a.stage_key})]}),c&&(0,j.jsx)("span",{className:"text-[11px] text-[var(--text-secondary)] italic truncate max-w-[60%]",t
2itle:a.failure_human||d||"","data-testid":`debug-queue-item-${a.id}-permanent`,children:a.failure_human||"Permanent \u2014 retrying cannot succeed."}),x&&(0,j.jsxs)("button",{type:"button",onClick:s,className:"inline-flex items-center gap-1 px-2 py-1 rounded text-[11px] font-semibold border border-[var(--border)] hover:bg-[var(--bg-surface)] text-[var(--text-primary)]","data-testid":`debug-queue-item-${a.id}-reset-retry`,children:[(0,j.jsx)(b.A,{className:"w-3 h-3"}),"Reset & Retry"]})]}),n&&(0,j.jsxs)("div",{className:`mt-2 px-2 py-1.5 rounded border ${n.bg} ${n.color} text-[11px] flex items-start gap-1.5`,children:[i&&(0,j.jsx)(i,{className:"w-3.5 h-3.5 mt-0.5 shrink-0"}),(0,j.jsx)("span",{children:n.label})]}),(0,j.jsxs)("div",{className:"text-[10px] text-[var(--text-secondary)] font-mono mt-1",children:["target=",a.target_user_instagram_id,null!==(t=a.payload_json)&&void 0!==t&&t.comment_id?` \xb7 cmt=${a.payload_json.comment_id}`:""]})]})}const F={private_reply:{label:"Private Reply API",cls:"bg-teal-500/10 border-teal-500/30 text-teal-600",title:"Sent via Meta's Private Replies API using comment_id \u2014 valid for 7 days from comment"},direct_dm:{label:"Direct DM",cls:"bg-zinc-500/10 border-zinc-500/30 text-zinc-600",title:"Sent directly to user inbox \u2014 requires prior conversation within 24h"}};function P(e){let{log:t}=e;const a=t.send_via&&F[t.send_via],s=t.result||"unknown",r="success"===s?"bg-teal-500/10 border-teal-500/30 text-teal-600":"rate_limited"===s?"bg-amber-500/10 border-amber-500/30 text-amber-600":"bg-red-500/10 border-red-500/30 text-red-600";return(0,j.jsxs)("div",{className:"rounded-md border border-[var(--border)] p-2 bg-[var(--bg-elevated)]","data-testid":`debug-send-log-${t.queue_item_id||"x"}`,children:[(0,j.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,j.jsx)("span",{className:`px-2 py-0.5 rounded text-[11px] font-semibold border ${r}`,children:s}),a&&(0,j.jsx)("span",{title:a.title,className:`px-2 py-0.5 rounded text-[11px] font-semibold border ${a.cls}`,"data-testid":`debug-send-log-via-${t.send_via}`,children:a.label}),(0,j.jsx)("span",{className:"text-[11px] text-[var(--text-secondary)] font-mono truncate flex-1",children:t.logged_at})]}),t.error_message&&(0,j.jsx)("div",{className:"mt-1 text-[11px] font-mono text-red-500 break-all",children:t.error_message.slice(0,220)})]})}function L(){const[e,t]=(0,s.useState)(null),[a,r]=(0,s.useState)(null),[d,o]=(0,s.useState)([]),[i,x]=(0,s.useState)(0),[m,b]=(0,s.useState)(!0),[y,k]=(0,s.useState)(""),[I,D]=(0,s.useState)(""),[M,q]=(0,s.useState)("24h"),[F,P]=(0,s.useState)(""),[L,z]=(0,s.useState)(""),[W,O]=(0,s.useState)(1),[E,U]=(0,s.useState)({}),[J,Q]=(0,s.useState)({}),[V,Y]=(0,s.useState)(null),[B,G]=(0,s.useState)(null),[H,K]=(0,s.useState)(""),X=(0,s.useMemo)(()=>{const e=new Date;if("custom"===M)return{date_from:F||void 0,date_to:L||void 0};const t={"1h":1,"6h":6,"24h":24,"7d":168}[M];if(!t)return{};return{date_from:new Date(e.getTime()-3600*t*1e3).toISOString(),date_to:e.toISOString()}},[M,F,L]),Z=(0,s.useCallback)(async()=>{try{const[e,a,s]=await Promise.all([g.F.get("/webhooks/stats"),g.F.get("/webhooks",{params:{status:y||void 0,event_type:I||void 0,date_from:X.date_from,date_to:X.date_to,page:W,limit:50}}),g.F.get("/webhooks/auto-retry/config").catch(()=>null)]);t(e),o(a.rows||[]),x(a.total||0),s&&r(s),K("")}catch(e){K((0,g.c)(e))}finally{b(!1)}},[y,I,X,W]);(0,s.useEffect)(()=>{Z()},[Z]),(0,f.T)(Z,12e4);const ee=(0,s.useMemo)(()=>["","message","comments","mentions","messaging_postbacks"],[]);return(0,j.jsxs)("div",{className:"p-6 max-w-7xl mx-auto","data-testid":"webhooks-page",children:[(0,j.jsxs)("div",{className:"flex items-center justify-between mb-6 gap-3",children:[(0,j.jsxs)("div",{children:[(0,j.jsxs)("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[(0,j.jsx)(n.A,{className:"w-6 h-6 text-[var(--accent)]"})," Webhooks",(null===a||void 0===a?void 0:a.enabled)&&(0,j.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[11px] font-semibold bg-teal-500/15 text-teal-600 dar
2k:text-teal-300 border border-teal-500/30","data-testid":"auto-retry-on-pill",title:`Re-queues failed events older than ${a.interval_mins}m`,children:[(0,j.jsx)(u.A,{className:"w-3 h-3"}),"Auto-retry: ON (",a.interval_mins,"m)"]})]}),(0,j.jsx)("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Live monitoring of Meta webhook deliveries. Auto-refreshes every 30s."})]}),(0,j.jsxs)("button",{onClick:Z,className:"inline-flex items-center gap-1.5 px-3 py-2 rounded-lg border border-[var(--border)] hover:bg-[var(--bg-elevated)] text-sm","data-testid":"webhooks-refresh-btn",children:[(0,j.jsx)(p.A,{className:"w-4 h-4 "+(m?"animate-spin":"")}),"Refresh"]})]}),(0,j.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 mb-3",children:[(0,j.jsx)(S,{label:"Total today",value:null===e||void 0===e?void 0:e.total_today,tone:"neutral",testId:"stat-total-today"}),(0,j.jsx)(S,{label:"Processed today",value:null===e||void 0===e?void 0:e.processed_today,tone:"teal",testId:"stat-processed-today"}),(0,j.jsx)(S,{label:"Pending today",value:null===e||void 0===e?void 0:e.pending_today,tone:"amber",testId:"stat-pending-today"}),(0,j.jsx)(S,{label:"Failed today",value:null===e||void 0===e?void 0:e.failed_today,tone:"red",testId:"stat-failed-today"})]}),(0,j.jsx)("div",{className:"mb-2 text-xs text-[var(--text-secondary)]","data-testid":"webhook-retention-note",children:$(e)}),(0,j.jsx)("div",{className:"mb-3 text-xs flex items-center gap-2","data-testid":"webhook-stats-freshness",children:!1===(null===e||void 0===e?void 0:e.stats_available)?(0,j.jsx)("span",{className:"text-[var(--danger)]",children:"Counts not computed yet \u2014 the precompute job hasn't run."}):null!==e&&void 0!==e&&e.stats_stale?(0,j.jsxs)("span",{className:"text-[var(--warning,#f6ad55)]",children:["\u26a0 Counts are stale \u2014 last updated ",_(e),"."]}):(0,j.jsxs)("span",{className:"text-[var(--text-secondary)]",children:["Counts updated ",_(e),"."]})}),(0,j.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 mb-6",children:[(0,j.jsx)(S,{label:A("Total",e),value:null===e||void 0===e?void 0:e.total_kept,tone:"neutral",testId:"stat-total-all"}),(0,j.jsx)(S,{label:A("Processed",e),value:null===e||void 0===e?void 0:e.processed_kept,tone:"teal",testId:"stat-processed-all"}),(0,j.jsx)(S,{label:A("Actionable",e),value:null===e||void 0===e?void 0:e.actionable_kept,tone:"neutral",testId:"stat-actionable-all"}),(0,j.jsx)(S,{label:"No idempotency key",value:null===e||void 0===e?void 0:e.unactionable_kept,tone:(null===e||void 0===e?void 0:e.unactionable_kept)>0?"amber":"neutral",testId:"stat-unactionable-all"})]}),(null===e||void 0===e?void 0:e.unactionable_kept)>0&&(0,j.jsxs)("div",{className:"mb-5 text-xs text-[var(--text-secondary)]","data-testid":"unactionable-note",children:[(0,j.jsx)("span",{className:"font-semibold text-[var(--text-primary)]",children:e.unactionable_kept.toLocaleString()})," ","rows have no idempotency key, so they never appear in the list below and cannot be retried or marked won't-fix. They are legacy rows from a duplicate insert that has since been removed, and the history cleanup will remove them as they pass ",e.retention_days||14," days old."]}),(0,j.jsx)(R,{}),null!=(null===e||void 0===e?void 0:e.avg_process_time_ms)&&e.avg_process_time_ms>0&&(0,j.jsxs)("div",{className:"mb-4 text-xs text-[var(--text-secondary)]",children:["Average processing time today:"," ",(0,j.jsxs)("span",{className:"font-semibold text-[var(--text-primary)]",children:[e.avg_process_time_ms," ms"]})]}),(0,j.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mb-3",children:[(0,j.jsxs)("select",{value:y,onChange:e=>{k(e.target.value),O(1)},className:"px-3 py-1.5 rounded-lg border border-[var(--border)] bg-[var(--bg-surface)] text-sm","data-testid":"webhooks-filter-status",children:[(0,j.jsx)("option",{value:"",children:"All statuses"}),(0,j.jsx)("option",{value:"processed",children:"Processed"}),(0,j.jsx)("option",{value:"pending",children:"Pending"}),(0,j.jsx)("option",{value:"failed",children:"Failed"}),(0,j.jsx)("option",{value:"wont_fix",children:"Won't Fix"})]}),(0,j.jsx)("select",{value:I,onChange:e=>{D(e.target.value),O(1)},className:"px-3 py-1.5 rounded-lg border border-[var(--border)] bg-[var(--bg-surface)] text-sm","data-testid":"webhooks-filter-event",children:ee.map(e=>(0,j.jsx)("option",{value:e,children:e||"All event types"},e||"all"))}),(0,j.jsxs)("div",{className:"inline-flex rounded-lg border border-[var(--border)] overflow-hidden","data-testid":"webhooks-filter-range",children:[(0,j.jsx)(v.A,{className:"w-3.5 h-3.5 self-center mx-2 text-[var(--text-secondary)]"}),[{v:"1h",l:"1h"},{v:"6h",l:"6h"},{v:"24h",l:"24h"},{v:"7d",l:"7d"},{v:"custom",l:"Custom"}].map(e=>(0,j.jsx)("button",{onClick:()=>{q(e.v),O(1)},className:"px-2.5 py-1.5 text-xs "+(M===e.v?"bg-[var(--accent)] text-white":"hover:bg-[var(--bg-elevated)]"),"data-testid":`webhooks-range-${e.v}`,children:e.l},e.v))]}),"custom"===M&&(0,j.jsxs)("div",{className:"flex items-center gap-1.5","data-testid":"webhooks-custom-range",children:[(0,j.jsx)("input",{type:"datetime-local",value:F,onChange:e=>{P(e.target.value?new Date(e.target.value).toISOString():""),O(1)},className:"px-2 py-1 rounded border border-[var(--border)] bg-[var(--bg-surface)] text-xs","data-testid":"webhooks-custom-from"}),(0,j.jsx)("span",{className:"text-xs text-[var(--text-secondary)]",children:"\u2192"}),(0,j.jsx)("input",{type:"datetime-local",value:L,onChange:e=>{z(e.target.value?new Date(e.target.value).toISOString():""),O(1)},className:"px-2 py-1 rounded border border-[var(--border)] bg-[var(--bg-surface)] text-xs","data-testid":"webhooks-custom-to"})]}),(0,j.jsxs)("span",{className:"ml-auto text-xs text-[var(--text-secondary)]",children:[i," total"]})]}),H&&(0,j.jsx)("div",{className:"mb-3 px-3 py-2 rounded-lg border border-red-500/30 bg-red-500/5 text-red-600 dark:text-red-300 text-sm","data-testid":"webhooks-error",children:H}),(0,j.jsx)("div",{className:"rounded-xl border border-[var(--border)] bg-[var(--bg-surface)] overflow-hidden",children:(0,j.jsx)("div",{className:"overflow-x-auto",children:(0,j.jsxs)("table",{className:"w-full text-sm","data-testid":"webhooks-table",children:[(0,j.jsx)("thead",{className:"bg-[var(--bg-elevated)] text-[var(--text-secondary)] text-xs uppercase",children:(0,j.jsxs)("tr",{children:[(0,j.jsx)("th",{className:"text-left px-4 py-2.5 font-semibold",children:"Received"}),(0,j.jsx)("th",{className:"text-left px-4 py-2.5 font-semibold",children:"Event"}),(0,j.jsx)("th",{className:"text-left px-4 py-2.5 font-semibold",children:"Signature"}),(0,j.jsx)("th",{className:"text-left px-4 py-2.5 font-semibold",children:"Status"}),(0,j.jsx)("th",{className:"text-left px-4 py-2.5 font-semibold",children:"Attempts"}),(0,j.jsx)("th",{className:"text-left px-4 py-2.5 font-semibold",children:"Error"}),(0,j.jsx)("th",{className:"text-right px-4 py-2.5 font-semibold",children:"Actions"})]})}),(0,j.jsxs)("tbody",{className:"divide-y divide-[var(--border)]",children:[m&&0===d.length&&(0,j.jsx)("tr",{children:(0,j.jsx)("td",{colSpan:7,className:"px-4 py-10 text-center text-[var(--text-secondary)]",children:(0,j.jsx)(c.A,{className:"w-5 h-5 animate-spin inline"})})}),!m&&0===d.length&&(0,j.jsx)("tr",{children:(0,j.jsx)("td",{colSpan:7,className:"px-4 py-10 text-center text-[var(--text-secondary)]","data-testid":"webhooks-empty",children:"No webhook events yet today."})}),d.map((e,t)=>{var a;return(0,j.jsxs)("tr",{className:"hover:bg-[var(--bg-elevated)]/40","data-testid":`webhook-row-${e.id||`legacy-${t}`}`,children:[(0,j.jsx)("td",{className:"px-4 py-2.5 text-xs whitespace-nowrap font-mono",children:w(e.received_at)}),(0,j.jsx)("td",{className:"px-4 py-2.5",children:(0,j.jsx)("span",{className:"px-2 py-0.5 rounded-md bg-[var(--accent-muted)] text-[var(--accent)] text-[11px] font-semibold",children:e.event_type||"\u2014"})}),(0,j.jsx)("td",{className:"px-4 py-2.5 text-xs",children:(0,j.jsx)(T,{status:e.signature_status})}),(0,j.jsxs)("td",{className:"px-4 py-2.5",children:[(0,j.jsx)(N,{status:e.status,receivedAt:e.received_at}),e.attempts>1&&(0,j.jsxs)("div",{className:"text-[10px] text-[var(--text-secondary)] mt-0.5","data-testid":`webhook-retried-${e.id}`,children:["Retried ",e.attempts-1,e.attempts-1===1?" time":" times"]})]}),(0,j.jsx)("td",{className:"px-4 py-2.5 text-xs",children:null!==(a=e.attempts)&&void 0!==a?a:0}),(0,j.jsx)("td",{className:"px-4 py-2.5 text-xs text-red-600 dark:text-red-300 max-w-[260px] truncate",title:e.error||"","data-testid":`webhook-error-${e.id}`,children:e.error_short||""}),(0,j.jsxs)("td",{className:"px-4 py-2.5 text-right whitespace-nowrap",children:[("failed"===e.status||"pending"===e.status)&&(0,j.jsxs)("button",{onClick:()=>(async e=>{U(t=>({...t,[e]:!0}));try{await g.F.post(`/webhooks/${encodeURIComponent(e)}/retry`),o(t=>t.map(t=>
2t.id===e?{...t,status:"pending",error:"",attempts:0}:t)),setTimeout(Z,2e3)}catch(t){K((0,g.c)(t))}finally{U(t=>({...t,[e]:!1}))}})(e.id),disabled:!!E[e.id],className:"inline-flex items-center gap-1 px-2 py-1 rounded-md border border-[var(--border)] hover:bg-[var(--bg-elevated)] text-xs mr-1 disabled:opacity-60","data-testid":`webhook-retry-${e.id}`,children:[E[e.id]?(0,j.jsx)(c.A,{className:"w-3 h-3 animate-spin"}):(0,j.jsx)(u.A,{className:"w-3 h-3"}),"Retry"]}),"failed"===e.status&&(0,j.jsxs)("button",{onClick:()=>Y(e.id),disabled:!!J[e.id],className:"inline-flex items-center gap-1 px-2 py-1 rounded-md border border-[var(--border)] hover:bg-[var(--bg-elevated)] text-xs mr-1 disabled:opacity-60 text-gray-600 dark:text-gray-300","data-testid":`webhook-wontfix-${e.id}`,title:"Mark as won't-fix \u2014 auto-retry will skip this event",children:[(0,j.jsx)(l,{className:"w-3 h-3"}),"Won't Fix"]}),"wont_fix"===e.status&&(0,j.jsxs)("button",{onClick:()=>(async e=>{Q(t=>({...t,[e]:!0}));try{await g.F.patch(`/webhooks/${encodeURIComponent(e)}/undo-wont-fix`),o(t=>t.map(t=>t.id===e?{...t,status:"failed"}:t))}catch(t){K((0,g.c)(t))}finally{Q(t=>({...t,[e]:!1}))}})(e.id),disabled:!!J[e.id],className:"inline-flex items-center gap-1 px-2 py-1 rounded-md border border-[var(--border)] hover:bg-[var(--bg-elevated)] text-xs mr-1 disabled:opacity-60","data-testid":`webhook-undo-wontfix-${e.id}`,title:"Undo \u2014 return event to failed so it can be retried",children:[J[e.id]?(0,j.jsx)(c.A,{className:"w-3 h-3 animate-spin"}):(0,j.jsx)(u.A,{className:"w-3 h-3"}),"Undo"]}),(0,j.jsxs)("button",{onClick:()=>G(e.id),className:"inline-flex items-center gap-1 px-2 py-1 rounded-md border border-[var(--border)] hover:bg-[var(--bg-elevated)] text-xs","data-testid":`webhook-view-${e.id}`,children:[(0,j.jsx)(h.A,{className:"w-3 h-3"})," View"]})]})]},e.id||`legacy-${e.received_at||""}-${t}`)})]})]})})}),i>50&&(0,j.jsxs)("div",{className:"mt-4 flex items-center justify-between text-sm text-[var(--text-secondary)]",children:[(0,j.jsxs)("span",{children:["Page ",W," of ",Math.max(1,Math.ceil(i/50))]}),(0,j.jsxs)("div",{className:"flex gap-2",children:[(0,j.jsx)("button",{onClick:()=>O(e=>Math.max(1,e-1)),disabled:1===W,className:"px-3 py-1.5 rounded-lg border border-[var(--border)] hover:bg-[var(--bg-elevated)] disabled:opacity-50","data-testid":"webhooks-prev-page",children:"Prev"}),(0,j.jsx)("button",{onClick:()=>O(e=>e+1),disabled:50*W>=i,className:"px-3 py-1.5 rounded-lg border border-[var(--border)] hover:bg-[var(--bg-elevated)] disabled:opacity-50","data-testid":"webhooks-next-page",children:"Next"})]})]}),(0,j.jsx)(C,{id:B,onClose:()=>G(null)}),V&&(0,j.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50",onClick:()=>Y(null),"data-testid":"wontfix-confirm-modal",children:(0,j.jsxs)("div",{className:"bg-[var(--bg-surface)] border border-[var(--border)] rounded-xl shadow-xl max-w-sm w-full p-5",onClick:e=>e.stopPropagation(),children:[(0,j.jsxs)("div",{className:"flex items-start gap-3",children:[(0,j.jsx)("div",{className:"w-10 h-10 rounded-full bg-gray-500/15 border border-gray-500/30 flex items-center justify-center shrink-0",children:(0,j.jsx)(l,{className:"w-5 h-5 text-gray-600 dark:text-gray-300"})}),(0,j.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,j.jsx)("div",{className:"text-sm font-semibold mb-1",children:"Mark this webhook as won't-fix?"}),(0,j.jsx)("p",{className:"text-xs text-[var(--text-secondary)]",children:"It will no longer be auto-retried. You can undo this from the table at any time."})]})]}),(0,j.jsxs)("div",{className:"flex justify-end gap-2 mt-4",children:[(0,j.jsx)("button",{onClick:()=>Y(null),className:"px-3 py-1.5 rounded-lg border border-[var(--border)] hover:bg-[var(--bg-elevated)] text-sm","data-testid":"wontfix-cancel",children:"Cancel"}),(0,j.jsxs)("button",{onClick:()=>(async e=>{Q(t=>({...t,[e]:!0})),Y(null);try{await g.F.patch(`/webhooks/${encodeURIComponent(e)}/wont-fix`,{reason:"manual"}),o(t=>t.map(t=>t.id===e?{...t,status:"wont_fix"}:t))}catch(t){K((0,g.c)(t))}finally{Q(t=>({...t,[e]:!1}))}})(V),className:"px-3 py-1.5 rounded-lg bg-gray-700 dark:bg-gray-200 text-white dark:text-gray-900 text-sm font-semibold inline-flex items-center gap-1","data-testid":"wontfix-confirm",children:[(0,j.jsx)(l,{className:"w-3.5 h-3.5"})," Confirm"]})]})]})})]})}function T(e){let{status:t}=e;const a="verified"===t,s=a?"bg-green-500/15 text-green-600 dark:text-green-300 border-green-500/30":"bg-gray-500/15 text-[var(--text-secondary)] border-[var(--border)]";return(0,j.jsxs)("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded border text-[10px] ${s}`,children:[(0,j.jsx)("span",{className:"w-1.5 h-1.5 rounded-full "+(a?"bg-green-500":"bg-gray-400")}),t]})}},28646(e,t,a){a.d(t,{A:()=>s});const s=(0,a(77784).A)("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]])},94805(e,t,a){a.d(t,{A:()=>s});const s=(0,a(77784).A)("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]])},30086(e,t,a){a.d(t,{A:()=>s});const s=(0,a(77784).A)("rotate-cw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]])}}]);
3//# sourceMappingURL=3042.ea8d93fd.chunk.js.map

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.