1import{u as e,c as t,d as s,a as o,j as a}from"./react-query-DbGahily.js";import{t as n,ae as i,a$ as r,az as l,G as c,af as d,ad as u,ba as b,aj as m,ah as x,ai as h,aZ as f,at as p,b4 as g,ak as k,ag as y,c9 as w,ca as j,cb as v,ab as _}from"./index-D2w6--me.js";import{F as N,a3 as S,D as R}from"./fontawesome-DBd3jlEg.js";import{T as W,a as C,b as F,c as E,d as A,e as $}from"./table-pDespjHN.js";import{t as z}from"./notifications-2QZES2T9.js";import{S as D}from"./SettingsSection-NqYIFN3L.js";import{I as P}from"./InternalWorkspaceWebhooksService-B1sbEiTN.js";import{W as V}from"./constants-Cc9WQnxZ.js";import{G as q,H as K,K as L}from"./date-fns-core-B257BzXA.js";import{N as Q}from"./router-Da9mPixd.js";import"./react-vendor-6ULW7vKx.js";import"./ui-utils-4YCDwm7v.js";import"./state-management-C8FSCvW-.js";import"./radix-ui-Bm2DdM33.js";import"./api-utils-DeT0SS0P.js";import"./tiptap-complete-BDArfEOb.js";import"./collaboration-protocols-oLklGwa8.js";import"./collaboration-provider-DYKWCpdb.js";import"./lucide-icons-jmdBoKez.js";import"./virtualization-BoefKlzQ.js";import"./react-day-picker-BRaEi7x0.js";import"./collapsible-CudBw1uJ.js";const T={all:["workspace-webhooks"],list:e=>[...T.all,e]};function I(){return P.getApiWorkspaceWebhooks()}function U(e){if(l(e))c.warn("Create webhook blocked by paywall:",e);else{if("endpoint_cap_exceeded"===d(e))return c.warn("Create webhook blocked by endpoint cap:",e),void z.error("Your planâs webhook endpoint limit has been reached. Disable or delete an existing endpoint, or upgrade your plan.");c.error("Failed to create webhook:",e),z.error("Failed to create webhook endpoint")}}function G(e){return P.postApiWorkspaceWebhooks(e)}function H(e){l(e)?c.warn("Rotate webhook secret blocked by paywall:",e):(c.error("Failed to rotate webhook secret:",e),z.error("Failed to rotate webhook signing secret"))}function O(e){return P.postApiWorkspaceWebhooksRotateSecret(e)}function X(e){l(e)?c.warn("Delete webhook blocked by paywall:",e):(c.error("Failed to delete webhook:",e),z.error("Failed to delete webhook endpoint"))}function Y(e){return P.deleteApiWorkspaceWebhooks(e)}function Z(e){l(e)?c.warn("Resend webhook verification blocked by paywall:",e):(c.error("Failed to resend webhook verification:",e),z.error("Failed to resend verification challenge"))}function B(e){return P.postApiWorkspaceWebhooksResendVerification(e)}function J(e){l(e)?c.warn("Re-enable webhook blocked by paywall:",e):(c.error("Failed to re-enable webhook:",e),z.error("Failed to re-enable webhook endpoint"))}function M(e){return P.postApiWorkspaceWebhooksReEnable(e)}function ee(e){if(!e)return"â";const t=q(e);return K(t)?L(t,{addSuffix:!0}):"â"}function te(){const l=n.c(69),{data:d,isLoading:w,isError:j,refetch:v}=function(){const t=n.c(5),{user:s}=i(),o=s?.workspace?.id;let a;t[0]!==o?(a=T.list(o),t[0]=o,t[1]=a):a=t[1];const l=!!o&&!0;let c;return t[2]!==a||t[3]!==l?(c={queryKey:a,queryFn:I,enabled:l,...r},t[2]=a,t[3]=l,t[4]=c):c=t[4],e(c)}(),_=function(){const e=n.c(2),o=t();let a;return e[0]!==o?(a={mutationFn:G,onSuccess:()=>{o.invalidateQueries({queryKey:T.all}),z.success("Webhook endpoint created")},onError:U},e[0]=o,e[1]=a):a=e[1],s(a)}(),$=function(){const e=n.c(2),o=t();let a;return e[0]!==o?(a={mutationFn:O,onSuccess:()=>{o.invalidateQueries({queryKey:T.all}),z.success("Webhook signing secret rotated")},onError:H},e[0]=o,e[1]=a):a=e[1],s(a)}(),P=function(){const e=n.c(2),o=t();let a;return e[0]!==o?(a={mutationFn:Y,onSuccess:()=>{o.invalidateQueries({queryKey:T.all}),z.success("Webhook endpoint deleted")},onError:X},e[0]=o,e[1]=a):a=e[1],s(a)}(),q=function(){const e=n.c(2),o=t();let a;return e[0]!==o?(a={mutationFn:M,onSuccess:()=>{o.invalidateQueries({queryKey:T.all}),z.success("Webhook endpoint re-enabled")},onError:J},e[0]=o,e[1]=a):a=e[1],s(a)}(),K=function(){const e=n.c(2),o=t();let a;return e[0]!==o?(a={mutationFn:B,onSuccess:e=>{o.invalidateQueries({queryKey:T.all}),"verified"===e.verification_state?z.success("Webhook endpoint verified"):z.success("Verification challenge sent")},onError:Z},e[0]=o,e[1]=a):a=e[1],s(a)}
1(),[L,Q]=o.useState(!1),[ee,te]=o.useState(null),[oe,ae]=o.useState("");let ne;l[0]===Symbol.for("react.memo_cache_sentinel")?(ne=[],l[0]=ne):ne=l[0];const[ie,re]=o.useState(ne);let le;l[1]!==d?.items?(le=d?.items??[],l[1]=d?.items,l[2]=le):le=l[2];const ce=le;let de;l[3]===Symbol.for("react.memo_cache_sentinel")?(de=()=>{ae(""),re([])},l[3]=de):de=l[3];const ue=de;let be;l[4]===Symbol.for("react.memo_cache_sentinel")?(be=e=>{re(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},l[4]=be):be=l[4];const me=be;let xe,he;l[5]!==oe?(he=oe.trim(),xe=he.startsWith("https://"),l[5]=oe,l[6]=xe,l[7]=he):(xe=l[6],he=l[7]);const fe=xe&&ie.length>0;let pe;l[8]!==fe||l[9]!==_||l[10]!==ie||l[11]!==he?(pe=async()=>{if(!fe)return;const e=await b(()=>_.mutateAsync({url:he,subscribed_events:ie}));e.ok&&(te(e.value.signing_secret??null),Q(!1),ue())},l[8]=fe,l[9]=_,l[10]=ie,l[11]=he,l[12]=pe):pe=l[12];const ge=pe;let ke;l[13]!==$?(ke=async e=>{const t=await b(()=>$.mutateAsync(e));t.ok&&te(t.value.signing_secret??null)},l[13]=$,l[14]=ke):ke=l[14];const ye=ke;let we;l[15]!==ee?(we=async()=>{if(!ee)return;const e=await b(()=>navigator.clipboard.writeText(ee));e.ok?z.success("Signing secret copied to clipboard"):(c.error("Failed to copy signing secret:",e.error),z.error("Failed to copy signing secret"))},l[15]=ee,l[16]=we):we=l[16];const je=we;let ve;l[17]!==P?(ve=async e=>{await b(()=>P.mutateAsync(e))},l[17]=P,l[18]=ve):ve=l[18];const _e=ve;let Ne;l[19]!==q?(Ne=async e=>{await b(()=>q.mutateAsync(e))},l[19]=q,l[20]=Ne):Ne=l[20];const Se=Ne;let Re;l[21]!==K?(Re=async e=>{await b(()=>K.mutateAsync(e))},l[21]=K,l[22]=Re):Re=l[22];const We=Re;let Ce;l[23]===Symbol.for("react.memo_cache_sentinel")?(Ce=()=>{Q(!0)},l[23]=Ce):Ce=l[23];const Fe=Ce;let Ee,Ae,$e,ze,De,Pe,Ve,qe,Ke,Le,Qe,Te;l[24]===Symbol.for("react.memo_cache_sentinel")?(Ee=a.jsx(u,{color:"primary",variant:"solid",icon:a.jsx(N,{icon:R}),onClick:Fe,"data-testid":"webhook-create-btn",children:"Create Webhook"}),l[24]=Ee):Ee=l[24],l[25]!==je||l[26]!==ee?(Ae=ee&&a.jsxs("div",{className:"flex w-full items-center gap-3 rounded-md border border-yellow-300 bg-yellow-50 p-3","data-testid":"webhook-revealed-secret",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm font-medium text-yellow-800",children:"Copy your signing secret now. It will not be shown again."}),a.jsx("code",{className:"mt-1 block text-xs break-all text-yellow-900",children:ee})]}),a.jsx(u,{color:"secondary",variant:"solid",size:"sm",onClick:je,"data-testid":"webhook-copy-secret-btn",children:"Copy"}),a.jsx(u,{color:"secondary",variant:"ghost",size:"sm",onClick:()=>te(null),"data-testid":"webhook-dismiss-secret-btn",children:"Dismiss"})]}),l[25]=je,l[26]=ee,l[27]=Ae):Ae=l[27],l[28]!==P||l[29]!==_e||l[30]!==Se||l[31]!==We||l[32]!==ye||l[33]!==j||l[34]!==w||l[35]!==q||l[36]!==v||l[37]!==K||l[38]!==$||l[39]!==ce?($e=a.jsx("div",{className:"w-full overflow-hidden rounded-md border border-gray-contio-200 bg-white shadow-sm",children:w?a.jsx("p",{className:"p-6 text-sm text-slate-500","data-testid":"webhook-section-loading",children:"Loading webhooksâ¦"}):j?a.jsxs("div",{className:"flex flex-col items-start gap-3 p-6","data-testid":"webhook-section-error",children:[a.jsx("p",{className:"text-sm text-slate-600",role:"alert",children:"We couldn't load your webhooks. Please try again."}),a.jsx(u,{color:"secondary",variant:"outline",size:"sm",onClick:()=>{v()},"data-testid":"webhook-section-retry",children:"Retry"})]}):0===ce.length?a.jsxs("div",{className:"flex flex-col items-center gap-2 px-6 py-12 text-center","data-testid":"webhook-empty-state",children:[a.jsx(N,{icon:S,className:"text-2xl text-slate-300"}),a.jsx("p",{className:"text-sm font-semibold text-zinc-900",children:"No webhook endpoints registered"}),a.jsx("p",{className:"max-w-sm text-xs text-slate-500",children:"Add an endpoint to start receiving event notifications."})]}):a.jsxs(W,{responsive:!0,children:[a.jsx(C,{children:a.jsxs(F,{className:"border-b border-gray-contio-200 bg-slate-50",children:[a.jsx(E,{className:"text-xs font-bold text-slate-500",children:"Endpoint"}),a.jsx(E,{className:"text-xs font-bold text-slate-500",children:"Status"}),a.jsx(E,{className:"text-xs font-bold text-slate-500",children:"Events"}),a.jsx(E,{className:"text-xs font-bold text-slate-500",children:"Created"}),a.jsx(E,{className:"text-xs font-bold text-slate-500",children:"Last success"}),a.jsx(E,{className:"sr-only text-xs font-bold text-slate-500",children:"Actions"})]})}),a.jsx(A,{children:ce.map(e=>a.jsx(se,{webhook:e,onDelete:_e,onReEnable:Se,onResendVerification:We,onRotate:ye,isDeleting:P.isPending,isRotating:$.isPending,isReEnabling:q.isPending,isResendingVerification:K.isPending},e.id))})]})}),l[28]=P,l[29]=_e,l[30]=Se,l[31]=We,l[32]=ye,l[33]=j,l[34]=w,l[35]=q,l[36]=v,l[37
1]=K,l[38]=$,l[39]=ce,l[40]=$e):$e=l[40],l[41]===Symbol.for("react.memo_cache_sentinel")?(ze=a.jsxs(m,{children:[a.jsx(x,{children:"Create Webhook Endpoint"}),a.jsx(h,{children:"Enter an HTTPS endpoint URL and select the events you want to receive."})]}),l[41]=ze):ze=l[41],l[42]===Symbol.for("react.memo_cache_sentinel")?(De=a.jsx(f,{htmlFor:"webhook-url",children:"Endpoint URL"}),l[42]=De):De=l[42],l[43]===Symbol.for("react.memo_cache_sentinel")?(Pe=e=>ae(e.target.value),l[43]=Pe):Pe=l[43],l[44]!==oe?(Ve=a.jsxs("div",{className:"flex flex-col gap-2",children:[De,a.jsx(p,{id:"webhook-url",type:"url",placeholder:"https://example.com/webhooks",value:oe,onChange:Pe,"data-testid":"webhook-url-input"})]}),l[44]=oe,l[45]=Ve):Ve=l[45],l[46]===Symbol.for("react.memo_cache_sentinel")?(qe=a.jsx(f,{children:"Events"}),l[46]=qe):qe=l[46],l[47]!==ie?(Ke=V.map(e=>a.jsx("button",{type:"button","aria-pressed":ie.includes(e.value),onClick:()=>me(e.value),className:"rounded-md border px-3 py-1.5 text-xs transition-colors "+(ie.includes(e.value)?"border-blue-500 bg-blue-50 text-blue-700":"border-gray-contio-200 text-slate-600 hover:border-gray-contio-300"),"data-testid":`webhook-event-toggle-${e.value}`,children:e.label},e.value)),l[47]=ie,l[48]=Ke):Ke=l[48],l[49]!==Ke?(Le=a.jsxs("div",{className:"flex flex-col gap-2",children:[qe,a.jsx("div",{className:"flex flex-wrap gap-2",children:Ke})]}),l[49]=Ke,l[50]=Le):Le=l[50],l[51]!==Ve||l[52]!==Le?(Qe=a.jsxs("div",{className:"flex flex-col gap-4 py-4",children:[Ve,Le]}),l[51]=Ve,l[52]=Le,l[53]=Qe):Qe=l[53],l[54]===Symbol.for("react.memo_cache_sentinel")?(Te=a.jsx(u,{color:"secondary",variant:"ghost",onClick:()=>Q(!1),children:"Cancel"}),l[54]=Te):Te=l[54];const Ie=!fe||_.isPending,Ue=_.isPending?"Creating...":"Create webhook";let Ge,He,Oe,Xe;return l[55]!==ge||l[56]!==Ie||l[57]!==Ue?(Ge=a.jsxs(g,{children:[Te,a.jsx(u,{color:"primary",variant:"solid",onClick:ge,disabled:Ie,"data-testid":"webhook-create-submit",children:Ue})]}),l[55]=ge,l[56]=Ie,l[57]=Ue,l[58]=Ge):Ge=l[58],l[59]!==Qe||l[60]!==Ge?(He=a.jsxs(k,{children:[ze,Qe,Ge]}),l[59]=Qe,l[60]=Ge,l[61]=He):He=l[61],l[62]!==L||l[63]!==He?(Oe=a.jsx(y,{open:L,onOpenChange:Q,children:He}),l[62]=L,l[63]=He,l[64]=Oe):Oe=l[64],l[65]!==Ae||l[66]!==$e||l[67]!==Oe?(Xe=a.jsxs(D,{title:"Webhook Endpoints","data-testid":"webhooks-section",action:Ee,children:[Ae,$e,Oe]}),l[65]=Ae,l[66]=$e,l[67]=Oe,l[68]=Xe):Xe=l[68],Xe}function se(e){const t=n.c(67),{webhook:s,onDelete:o,onReEnable:i,onResendVerification:r,onRotate:l,isDeleting:c,isRotating:d,isReEnabling:b,isResendingVerification:m}=e;let x;t[0]!==o||t[1]!==s.id||t[2]!==s.url?(x=()=>{s.id&&window.confirm(`Delete webhook endpoint "${s.url}"? This action cannot be undone.`)&&o(s.id)},t[0]=o,t[1]=s.id,t[2]=s.url,t[3]=x):x=t[3];const h=x;let f;t[4]!==l||t[5]!==s.id?(f=()=>{s.id&&l(s.id)},t[4]=l,t[5]=s.id,t[6]=f):f=t[6];const p=f;let g;t[7]!==i||t[8]!==s.id?(g=()=>{s.id&&i(s.id)},t[7]=i,t[8]=s.id,t[9]=g):g=t[9];const k=g;let y;t[10]!==r||t[11]!==s.id?(y=()=>{s.id&&r(s.id)},t[10]=r,t[11]=s.id,t[12]=y):y=t[12];const w=y,j=`webhook-row-${s.id}`,v=`webhook-url-${s.id}`;let _,N,S,R;t[13]!==v||t[14]!==s.url?(_=a.jsx($,{className:"font-medium text-zinc-900",children:a.jsx("span",{className:"block max-w-xs truncate","data-testid":v,children:s.url})}),t[13]=v,t[14]=s.url,t[15]=_):_=t[15],t[16]!==s.status||t[17]!==s.verification_state?(N=a.jsx(oe,{status:s.status,verificationState:s.verification_state}),t[16]=s.status,t[17]=s.verification_state,t[18]=N):N=t[18],t[19]!==s.consecutive_failure_count?(S=a.jsx(ae,{failureCount:s.consecutive_failure_count}),t[19]=s.consecutive_failure_count,t[20]=S):S=t[20],t[21]!==N||t[22]!==S?(R=a.jsx($,{className:"text-xs text-slate-600",children:a.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[N,S]})}),t[21]=N,t[22]=S,t[23]=R):R=t[23];const W=`webhook-event-count-${s.id}`,C=s.subscribed_events?.length??0;let E,A,z;t[24]!==W||t[25]!==C?(E=a.jsx($,{className:"text-xs text-slate-600","data-testid":W,children:C}),t[24]=W,t[25]=C,t[26]=E):E=t[26],t[27]!==s.created_at?(A=ee(s.created_at),t[27]=s.created_at,t[28]=A):A=t[28],t[29]!==A?(z=a.jsx($,{className:"text-xs text-slate-600",children:A}),t[29]=A,t[30]=z):z=t[30];const D=`webhook-last-success-${s.id}`;let P,V,q,K;t[31]!==s.last_success_at?(P=s.last_success_at?ee(s.last_success_at):"Never",t[31]=s.last_success_at,t[32]=P):P=t[32],t[33]!==D||t[34]!==P?(V=a.jsx($,{className:"text-xs text-slate-600","data-testid":D,children:P}),t[33]=D,t[34]=P,t[35]=V):V=t[35],t[36]!==w||t[37]!==m||t[38]!==s.id||t[39]!==s.verification_state?(q="failed"===s.verification_state&&a.jsx(u,{color:"secondary",variant:"outline",size:"xs",onClick:w,disabled:m,"data-testid":`webhook-resend-verification-${s.id}`,children:m?"Resending...":"Resend verification"}),t[36]=w,t[37]=m,t[38]=s.id,t[39]=s.verification_state,t[40]=q):q=t[40],t[41]!==k||t[42]!==b||t[43]!==s.id||t[44]!==s.status?(K="disabled"===s.status&&a.jsx(u,{color:"secondary",variant:"outline",size:"xs",onClick:k,disabled:b,"data-testid":`webhook-reenable-${s.id}`,children:b?"Re-enabling...":"Re-enable"}),t[41]=k,t[42]=b,t[43]=s.id,t[44]=s.status,t[45]=K):K=t[45];const L=`webhook-rotate-${s.id}`;let Q;t[46]!==p||t[47]!==d||t[48]!==L?(Q=a.jsx(u,{color:"secondary",variant:"outline",size:"xs",onClick:p,disabled:d,"data-testid":L,children:"Rotate secret"}),t[46]=p,t[47]=d,t[48]=L,t[49]=Q):Q=t[49];const T=`webhook-delete-${s.id}`;let I,U,G;return t[50]!==h||t[51]!==c||t[52]!==T?(I=a.jsx(u,{color:"danger",variant:"outline",size:"xs",onClick:h,disabled:c,"data-testid":T,children:"Delete"}),t[50]=h,t[51]=c,t[52]=T,t[53]=I):I=t[53],t[54]!==q||t[55]!==K||t[56]!==Q||t[57]!==I?(U=a.jsx($,{className:"text-right",children:a.jsxs("div",{className:"flex items-center justify-end gap-2",children:[q,K,Q,I]})}),t[54]=q,t[55]=K,t[56]=Q,t[57]=I,t[58]=U):U=t[58],t[59]!==R||t[60]!==E||t[61]!==z||t[62]!==V||t[63]!==U||t[64]!==j||t[65]!==_?
1(G=a.jsxs(F,{"data-testid":j,children:[_,R,E,z,V,U]}),t[59]=R,t[60]=E,t[61]=z,t[62]=V,t[63]=U,t[64]=j,t[65]=_,t[66]=G):G=t[66],G}function oe(e){const t=n.c(7),{status:s,verificationState:o}=e;let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i={verified:{className:"bg-green-100 text-green-800",label:"Verified"},verifying:{className:"bg-yellow-100 text-yellow-800",label:"Verifying"},failed:{className:"bg-red-100 text-red-800",label:"Verification failed"},pending:{className:"bg-yellow-100 text-yellow-800",label:"Pending"},disabled:{className:"bg-red-100 text-red-800",label:"Disabled"}},t[0]=i):i=t[0];const r=i,l=o??s??"";let c;t[1]!==l||t[2]!==s?(c=r[l]??{className:"bg-gray-100 text-gray-800",label:s??"Unknown"},t[1]=l,t[2]=s,t[3]=c):c=t[3];const d=c,u=`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${d.className}`;let b;return t[4]!==d.label||t[5]!==u?(b=a.jsx("span",{className:u,"data-testid":"webhook-status-badge",children:d.label}),t[4]=d.label,t[5]=u,t[6]=b):b=t[6],b}function ae(e){const t=n.c(4),{failureCount:s}=e;if(!s||0===s)return null;const o=`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${s<3?"bg-orange-100 text-orange-800":"bg-red-100 text-red-800"}`,i=s>1?"s":"";let r;return t[0]!==s||t[1]!==o||t[2]!==i?(r=a.jsxs("span",{className:o,"data-testid":"webhook-delivery-health-badge",children:[s," failure",i]}),t[0]=s,t[1]=o,t[2]=i,t[3]=r):r=t[3],r}const ne=()=>{const e=n.c(4),{user:t}=i();if(!t){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=a.jsx(v,{}),e[0]=t):t=e[0],t}if(!w("edit_workspace_settings",j(t)).hasPermission){let t;return e[1]===Symbol.for("react.memo_cache_sentinel")?(t=a.jsx(Q,{to:"/settings/developer/tokens",replace:!0}),e[1]=t):t=e[1],t}let s,o;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(_,{title:"Webhooks"}),e[2]=s):s=e[2],e[3]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsxs("div",{className:"flex h-full flex-col","data-testid":"developer-webhooks-page",children:[s,a.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto bg-gray-contio-50 p-4 pb-22",children:a.jsx(te,{})})]}),e[3]=o):o=e[3],o};export{ne 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.