1import{d as J,Y as X,as as Z,ae as ee,K as te,f as oe,g as T,L as se,e as c,j as o,k as u,h as t,v as b,x as re,D as ne,I as m,t as x,G as v,i as V,H as g,F as S,l as y,y as B,B as ae,J as le,r as E,q as C,n as de}from"./5ED1w5_O.js";import{_ as ie}from"./DrdrK4IF.js";import{_ as ce}from"./Bp5Bqixh.js";import{_ as ue}from"./BqL4yBOL.js";import{u as pe,W as me,T as be,w as xe,a as fe}from"./BHWr6iW9.js";import{u as ve}from"./B6WDX1Ww.js";import"./BI--CUhV.js";import"./XLTdtFqi.js";import"./DxoTWDPe.js";const ge={key:0,class:"space-y-6"},he={class:"admin-card flex flex-col gap-4 p-5"},ye={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4"},ke={class:"flex items-center gap-3 mb-2"},we={class:"admin-card flex flex-col gap-4 p-5"},_e={class:"space-y-4"},Ce={key:0},Ue={class:"block text-sm font-medium text-card-text mb-2"},Te=["placeholder"],Ve={key:0,class:"text-xs text-destructive mt-1"},Ee={key:1,class:"text-xs text-card-text-secondary mt-1"},Pe={key:0,class:"text-xs text-destructive mt-1"},Ae={key:1,class:"text-xs text-card-text-secondary mt-1"},Le={key:0,class:"text-xs text-destructive mt-1"},Se={key:1,class:"text-xs text-card-text-secondary mt-1"},Re=["placeholder"],Be={key:0,class:"text-xs text-destructive mt-1"},Ke={class:"admin-card flex flex-col gap-4 p-5"},De={key:0,class:"text-xs text-destructive mt-1"},Oe={class:"flex items-start gap-3 p-3 bg-card-button-subtle border border-[var(--admin-border)] rounded-lg"},$e={key:0,class:"admin-card flex flex-col gap-4 p-5"},Ie={class:"text-sm font-semibold text-card-text mb-3"},We={key:0,class:"space-y-3"},je=["onUpdate:modelValue","placeholder"],ze=["onUpdate:modelValue","placeholder"],Me={class:"flex gap-2 items-center"},He=["title","onClick"],Ne=["onUpdate:modelValue"],Ge={key:1,class:"space-y-3"},qe=["onUpdate:modelValue","placeholder"],Fe=["onUpdate:modelValue","placeholder"],Qe={key:2,class:"space-y-3"},Ye=["onUpdate:modelValue","placeholder"],Je=["onUpdate:modelValue","placeholder"],Xe={class:"mt-3"},Ze={class:"mt-2 grid grid-cols-1 gap-1"},et=["title","onClick"],tt={class:"text-card-text-secondary"},ot={class:"text-card-text-secondary/50"},st={key:1,class:"p-4 rounded-lg border border-red-500/30 bg-red-500/10"},rt={class:"text-destructive"},nt={class:"flex gap-4"},ft=J({__name:"new",setup(at){X({title:"Create Webhook Endpoint",minimal:!0});const P=se(),D=Z(),{can:O}=ve(),{createEndpoint:$}=pe();O("webhooks.write")||(P.error("You do not have permission to create webhook endpoints"),ee("/admin/webhooks"));const a=E(null),A=n=>{a.value=n,l.value.url="",l.value.pushoverToken="",l.value.pushoverUserKey="",l.value.description="",l.value.events=[];for(const e of Object.keys(d))d[e]={}},I=()=>{a.value=null},W=C(()=>a.value==="discord"?"Discord":a.value==="slack"?"Slack":a.value==="pushover"?"Pushover":"Custom URL"),j=C(()=>a.value==="discord"?"simple-icons:discord":a.value==="slack"?"simple-icons:slack":a.value==="pushover"?"tabler:brand-pushover":"heroicons:code-bracket-20-solid"),z=C(()=>a.value==="discord"?"Discord Webhook URL":a.value==="slack"?"Slack Webhook URL":"URL"),M=C(()=>a.value==="discord"?"https://discord.com/api/webhooks/...":a.value==="slack"?"https://hooks.slack.com/services/...":"https://example.com/webhooks"),H=C(()=>a.value==="discord"?"Paste your Discord channel webhook URL (Server Settings > Integrations > Webhooks)":a.value==="slack"?"Paste your Slack incoming webhook URL (Apps > Incoming Webhooks)":"Must be a valid HTTPS URL. Payloads are signed with HMAC-SHA256."),N=C(()=>a.value==="discord"?"e.g., #competition-alerts channel":a.value==="slack"?"e.g., #orders-feed channel":a.value==="pushover"?"e.g., Admin phones (ops group)":"e.g., Production order notifications"),d=te(Object.fromEntries(me.map(n=>[n.value,{}]))),G=[{value:"#2ECC71",label:"Green"},{value:"#3498DB",label:"Blue"},{value:"#E74C3C",label:"Red"},{value:"#F1C40F",label:"Gold"},{value:"#9B59B6",label:"Purple"}],K={},R=(n,e)=>{e&&(K[n]=e)},q=(n,e)=>{d[n]||(d[n]={});const p=K[n],f=d[n].body||"",h=p?.selectionStart??f.length,w=p?.selectionEnd??f.length;d[n].body=f.slice(0,h)+e+f.slice(w),de(()=>{if(!p)return;p.focus();const _=h+e.length;p.setSelectionRange(_,_)})},F=n=>xe(n),k=(n,e)=>fe(n,e),l=E({url:"",pushoverToken:"",pushoverUserKey:"",description:"",events:[]}),L=E(!1),U=E(""),i=E({}),Q=async()=>
1{if(L.value=!0,U.value="",i.value={},l.value.events.length===0){i.value.events="At least one event must be selected",L.value=!1;return}try{const n={events:l.value.events};a.value==="pushover"?(n.format="pushover",n.pushoverToken=l.value.pushoverToken.trim(),n.pushoverUserKey=l.value.pushoverUserKey.trim()):n.url=l.value.url,l.value.description&&(n.description=l.value.description);const e={};if(a.value!=="raw")for(const f of l.value.events){const h=d[f];h&&Object.values(h).some(w=>w)&&(e[f]=Object.fromEntries(Object.entries(h).filter(([w,_])=>_)))}Object.keys(e).length>0&&(n.messageConfig=e);const p=await $(n);P.success("Webhook endpoint created"),D.push(`/admin/webhooks/${p.data.id}`)}catch(n){if(n.data?.details&&Array.isArray(n.data.details))for(const e of n.data.details){const p=e.field?.replace("body.","")||"";p&&(i.value[p]=e.message)}if(Object.keys(i.value).length>0){const e=Object.values(i.value).join(", ");U.value=e,P.error(e)}else{const e=n.data?.message||n.data?.error||"Failed to create webhook endpoint";U.value=e,P.error(e)}}finally{L.value=!1}};return(n,e)=>{const p=re,f=le,h=ie,w=ce,_=ue;return c(),oe(_,{title:"Create Webhook Endpoint",description:"Add a new endpoint to receive platform event notifications","max-width":"4xl"},{actions:T(()=>[b(f,{to:"/admin/webhooks",variant:"outline"},{default:T(()=>[b(p,{name:"heroicons:arrow-left",class:"w-4 h-4 mr-2"}),e[13]||(e[13]=m(" Back to List ",-1))]),_:1})]),default:T(()=>[o(a)?(c(),u("form",{key:1,onSubmit:ne(Q,["prevent"]),class:"space-y-6"},[t("div",ke,[t("button",{type:"button",class:"flex items-center gap-2 text-sm text-card-text-secondary hover:text-card-text transition-colors",onClick:I},[b(p,{name:"heroicons:arrow-left-20-solid",class:"w-4 h-4"}),e[20]||(e[20]=m(" Change type ",-1))]),b(h,{icon:o(j),label:o(W)},null,8,["icon","label"])]),t("div",we,[e[27]||(e[27]=t("h2",{class:"admin-section-title mb-4"},"Endpoint Details",-1)),t("div",_e,[o(a)!=="pushover"?(c(),u("div",Ce,[t("label",Ue,[m(x(o(z))+" ",1),e[21]||(e[21]=t("span",{class:"text-destructive"},"*",-1))]),v(t("input",{"onUpdate:modelValue":e[4]||(e[4]=s=>o(l).url=s),type:"url",placeholder:o(M),required:"",class:V(["w-full px-3 py-2 bg-card-button-subtle border rounded-md text-card-text font-mono text-sm focus:ring-2 focus:border-transparent",o(i).url?"border-destructive focus:ring-destructive":"border-[var(--admin-border)] focus:ring-admin-accent-ring"]),onInput:e[5]||(e[5]=s=>delete o(i).url)},null,42,Te),[[g,o(l).url]]),o(i).url?(c(),u("p",Ve,x(o(i).url),1)):(c(),u("p",Ee,x(o(H)),1))])):(c(),u(S,{key:1},[t("div",null,[e[23]||(e[23]=t("label",{class:"block text-sm font-medium text-card-text mb-2"},[m(" Application Token "),t("span",{class:"text-destructive"},"*")],-1)),v(t("input",{"onUpdate:modelValue":e[6]||(e[6]=s=>o(l).pushoverToken=s),type:"text",placeholder:"e.g. azGDORePK8gMaC0QOYAMyEEuzJnyUi",required:"",autocomplete:"off",spellcheck:"false",class:V(["w-full px-3 py-2 bg-card-button-subtle border rounded-md text-card-text font-mono text-sm focus:ring-2 focus:border-transparent",o(i).pushoverToken?"border-destructive focus:ring-destructive":"border-[var(--admin-border)] focus:ring-admin-accent-ring"]),onInput:e[7]||(e[7]=s=>delete o(i).pushoverToken)},null,34),[[g,o(l).pushoverToken]]),o(i).pushoverToken?(c(),u("p",Pe,x(o(i).pushoverToken),1)):(c(),u("p",Ae,[...e[22]||(e[22]=[m(" Create a free application at ",-1),t("a",{href:"https://pushover.net/apps/build",target:"_blank",rel:"noopener",class:"text-admin-accent-text hover:text-admin-accent-text-hover underline"},"pushover.net/apps/build",-1),m(" using your site's name, then copy its API token here. Each application includes 10,000 free messages a month. ",-1)])]))]),t("div",null,[e[25]||(e[25]=t("label",{class:"block text-sm font-medium text-card-text mb-2"},[m(" User or Group Key "),t("span",{class:"text-destructive"},"*")],-1)),v(t("input",{"onUpdate:modelValue":e[8]||(e[8]=s=>o(l).pushoverUserKey=s),type:"text",placeholder:"e.g. uQiRzpo4DXghDmr9QzzfQu27cmVRsG",required:"",autocomplete:"off",spellcheck:"false",class:V(["w-full px-3 py-2 bg-card-button-subtle border rounded-md text-card-text font-mono text-sm focus:ring-2 focus:border-transparent",o(i).pushoverUserKey?"border-destructive focus:ring-destructive":"border-[var(--admin-border)] focus:ring-admin-accent-ring"]),onInput:e[9]||(e[9]=s=>delete o(i).pushoverUserKey)},null,34),[[g,o(l).pushoverUserKey]]),o(i).pushoverUserKey?(c(),u("p",Le,x(o(i).pushoverUserKey),1)):(c(),u("p",Se,[...e[24]||(e[24]=[m(" Your key is on the ",-1),t("a",{href:"https://pushover.net",target:"_blank",rel:"noopener",class:"text-admin-accent-text hover:text-admin-accent-text-hover underline"},"Pushover dashboard",-1),m(". To notify several admins, create a ",-1),t("a",{href:"https://pushover.net/groups/build",target:"_blank",rel:"noopener",class:"text-admin-accent-text hover:text-admin-accent-text-hover underline"},"delivery group",-1),m(", add each admin's Pushover account to it, and paste the group key instead â you manage who's in the group on Pushover, without touching this form again. ",-1)])]))])],64)),t("div",null,[e[26]||(e[26]=t("label",{class:"block text-sm font-medium text-card-text mb-2"},"Description",-1)),v(t("input",{"onUpdate:modelValue":e[10]||(e[10]=s=>o(l).description=s),type:"text",placeholder:o(N),maxlength:"255",class:V(["w-full px-3 py-2 bg-card-button-subtle border rounded-md text-card-text focus:ring-2 focus:border-transparent",o(i).description?"border-destructive focus:ring-destructive":"border-[var(--admin-border)] focus:ring-admin-accent-ring"]),onInput:e[11]||(e[11]=s=>delete o(i).description)},null,42,Re),[[g,o(l).description]]),o(i).description?(c(),u("p",Be,x(o(i).description),1)):y("",!0)])])]),t("div",Ke,[e[29]||(e[29]=t("h2",{class:"admin-section-title mb-4"},"Events",-1)),e[30]||(e[30]=t("p",{class:"text-sm text-card-text-secondary mb-2"},"Select which events this endpoint should receive. At least one is required.",-1)),b(w,{modelValue:o(l).events,"onUpdate:modelValue":e[12]||(e[12]=s=>
1o(l).events=s),"channel-warning":o(a)!=="pushover"},null,8,["modelValue","channel-warning"]),o(i).events?(c(),u("p",De,x(o(i).events),1)):y("",!0),t("div",Oe,[b(p,{name:"heroicons:light-bulb",class:"w-4 h-4 text-card-text-muted mt-0.5 shrink-0"}),e[28]||(e[28]=t("p",{class:"text-xs text-card-text-secondary"},[m("Need a different event? "),t("a",{href:"mailto:[email protected]",class:"text-admin-accent-text hover:text-admin-accent-text-hover underline"},"Let us know"),m(" and we can investigate.")],-1))])]),o(a)!=="raw"&&o(l).events.length>0?(c(),u("div",$e,[e[41]||(e[41]=t("h2",{class:"admin-section-title mb-2"},"Message Customisation",-1)),e[42]||(e[42]=t("p",{class:"text-sm text-card-text-secondary mb-4"},[m("Customise how webhook messages appear. Leave fields empty to use defaults. Use template variables like "),t("code",{class:"text-xs bg-card-button-subtle px-1 py-0.5 rounded",textContent:"{{competition.title}}"}),m(" for dynamic content.")],-1)),(c(!0),u(S,null,B(o(l).events,s=>(c(),u("div",{key:s,class:"border border-[var(--admin-border)] rounded-lg p-4"},[t("h3",Ie,x(F(s)),1),o(a)==="discord"?(c(),u("div",We,[t("div",null,[e[31]||(e[31]=t("label",{class:"block text-xs font-medium text-card-text-secondary mb-1"},"Title",-1)),v(t("input",{"onUpdate:modelValue":r=>o(d)[s].title=r,type:"text",maxlength:"256",placeholder:k(s,"title"),class:"w-full px-3 py-2 bg-card-button-subtle border border-[var(--admin-border)] rounded-md text-card-text text-sm focus:ring-2 focus:ring-admin-accent-ring focus:border-transparent"},null,8,je),[[g,o(d)[s].title]])]),t("div",null,[e[32]||(e[32]=t("label",{class:"block text-xs font-medium text-card-text-secondary mb-1"},"Body",-1)),v(t("textarea",{ref_for:!0,ref:r=>R(s,r),"onUpdate:modelValue":r=>o(d)[s].body=r,maxlength:"4096",rows:"3",placeholder:k(s,"body"),class:"w-full px-3 py-2 bg-card-button-subtle border border-[var(--admin-border)] rounded-md text-card-text text-sm focus:ring-2 focus:ring-admin-accent-ring focus:border-transparent resize-y"},null,8,ze),[[g,o(d)[s].body]])]),t("div",null,[e[33]||(e[33]=t("label",{class:"block text-xs font-medium text-card-text-secondary mb-1"},"Embed Colour",-1)),t("div",Me,[(c(),u(S,null,B(G,r=>t("button",{key:r.value,type:"button",class:V(["w-7 h-7 rounded-full border-2 transition-all",o(d)[s].color===r.value?"border-card-text scale-110":"border-transparent"]),style:ae({backgroundColor:r.value}),title:r.label,onClick:Y=>o(d)[s].color=r.value},null,14,He)),64)),v(t("input",{"onUpdate:modelValue":r=>o(d)[s].color=r,type:"text",placeholder:"#2ECC71",maxlength:"7",class:"w-24 px-2 py-1 bg-card-button-subtle border border-[var(--admin-border)] rounded-md text-card-text text-sm font-mono focus:ring-2 focus:ring-admin-accent-ring focus:border-transparent"},null,8,Ne),[[g,o(d)[s].color]])])])])):y("",!0),o(a)==="slack"?(c(),u("div",Ge,[t("div",null,[e[34]||(e[34]=t("label",{class:"block text-xs font-medium text-card-text-secondary mb-1"},"Header",-1)),v(t("input",{"onUpdate:modelValue":r=>o(d)[s].header=r,type:"text",maxlength:"150",placeholder:k(s,"header"),class:"w-full px-3 py-2 bg-card-button-subtle border border-[var(--admin-border)] rounded-md text-card-text text-sm focus:ring-2 focus:ring-admin-accent-ring focus:border-transparent"},null,8,qe),[[g,o(d)[s].header]])]),t("div",null,[e[35]||(e[35]=t("label",{class:"block text-xs font-medium text-card-text-secondary mb-1"},"Body",-1)),v(t("textarea",{ref_for:!0,ref:r=>R(s,r),"onUpdate:modelValue":r=>o(d)[s].body=r,maxlength:"3000",rows:"3",placeholder:k(s,"body"),class:"w-full px-3 py-2 bg-card-button-subtle border border-[var(--admin-border)] rounded-md text-card-text text-sm focus:ring-2 focus:ring-admin-accent-ring focus:border-transparent resize-y"},null,8,Fe),[[g,o(d)[s].body]]),e[36]||(e[36]=t("p",{class:"text-xs text-card-text-secondary mt-1"},"Supports Slack mrkdwn: *bold*, _italic_, `code`",-1))])])):y("",!0),o(a)==="pushover"?(c(),u("div",Qe,[t("div",null,[e[37]||(e[37]=t("label",{class:"block text-xs font-medium text-card-text-secondary mb-1"},"Title",-1)),v(t("input",{"onUpdate:modelValue":r=>o(d)[s].title=r,type:"text",maxlength:"250",placeholder:k(s,"title"),class:"w-full px-3 py-2 bg-card-button-subtle border border-[var(--admin-border)] rounded-md text-card-text text-sm focus:ring-2 focus:ring-admin-accent-ring focus:border-transparent"},null,8,Ye),[[g,o(d)[s].title]])]),t("div",null,[e[38]||(e[38]=t("label",{class:"block text-xs font-medium text-card-text-secondary mb-1"},"Message",-1)),v(t("textarea",{ref_for:!0,ref:r=>R(s,r),"onUpdate:modelValue":r=>o(d)[s].body=r,maxlength:"1024",rows:"3",placeholder:k(s,"body"),class:"w-full px-3 py-2 bg-card-button-subtle border border-[var(--admin-border)] rounded-md text-card-text text-sm focus:ring-2 focus:ring-admin-accent-ring focus:border-transparent resize-y"},null,8,Je),[[g,o(d)[s].body]]),e[39]||(e[39]=t("p",{class:"text-xs text-card-text-secondary mt-1"},"Plain text â notifications are capped at 1,024 characters",-1))])])):y("",!0),t("details",Xe,[e[40]||(e[40]=t("summary",{class:"text-xs text-card-text-secondary cursor-pointer hover:text-card-text transition-colors"},[m("Available variables "),t("span",{class:"text-card-text-secondary/50"}
1,"â click to insert into the body")],-1)),t("div",Ze,[(c(!0),u(S,null,B(o(be)[s],r=>(c(),u("div",{key:r.key,class:"flex items-center gap-2 text-xs"},[t("button",{type:"button",title:`Insert ${r.key} into the body`,class:"bg-card-button-subtle px-1.5 py-0.5 rounded text-card-text font-mono hover:bg-card-button-subtle-hover transition-colors cursor-pointer",onClick:Y=>q(s,r.key)},x(r.key),9,et),t("span",tt,x(r.description),1),t("span",ot,"e.g. "+x(r.example),1)]))),128))])])]))),128))])):y("",!0),o(U)?(c(),u("div",st,[t("p",rt,x(o(U)),1)])):y("",!0),t("div",nt,[b(f,{type:"submit",loading:o(L)},{default:T(()=>[...e[43]||(e[43]=[m(" Create Endpoint ",-1)])]),_:1},8,["loading"]),b(f,{to:"/admin/webhooks",variant:"outline"},{default:T(()=>[...e[44]||(e[44]=[m(" Cancel ",-1)])]),_:1})])],32)):(c(),u("div",ge,[t("div",he,[e[18]||(e[18]=t("h2",{class:"admin-section-title mb-2"},"Where are you sending webhooks?",-1)),e[19]||(e[19]=t("p",{class:"text-sm text-card-text-secondary mb-4"},"Choose a destination to get started. This determines the payload format and available customisation options.",-1)),t("div",ye,[t("button",{type:"button",class:"flex flex-col items-center gap-3 p-5 bg-card border border-[var(--admin-border)] rounded-lg hover:bg-card-button-subtle transition-colors text-left focus:outline-hidden focus-visible:ring-2 focus-visible:ring-admin-accent-ring",onClick:e[0]||(e[0]=s=>A("discord"))},[b(p,{name:"simple-icons:discord",class:"w-8 h-8 text-card-text"}),e[14]||(e[14]=t("div",{class:"text-center"},[t("span",{class:"block text-card-text font-semibold text-base"},"Discord"),t("span",{class:"text-xs text-card-text-secondary mt-1"},"Rich embeds with colours, titles and formatted messages")],-1))]),t("button",{type:"button",class:"flex flex-col items-center gap-3 p-5 bg-card border border-[var(--admin-border)] rounded-lg hover:bg-card-button-subtle transition-colors text-left focus:outline-hidden focus-visible:ring-2 focus-visible:ring-admin-accent-ring",onClick:e[1]||(e[1]=s=>A("slack"))},[b(p,{name:"simple-icons:slack",class:"w-8 h-8 text-card-text"}),e[15]||(e[15]=t("div",{class:"text-center"},[t("span",{class:"block text-card-text font-semibold text-base"},"Slack"),t("span",{class:"text-xs text-card-text-secondary mt-1"},"Block Kit messages with headers and mrkdwn formatting")],-1))]),t("button",{type:"button",class:"flex flex-col items-center gap-3 p-5 bg-card border border-[var(--admin-border)] rounded-lg hover:bg-card-button-subtle transition-colors text-left focus:outline-hidden focus-visible:ring-2 focus-visible:ring-admin-accent-ring",onClick:e[2]||(e[2]=s=>A("pushover"))},[b(p,{name:"tabler:brand-pushover",class:"w-8 h-8 text-card-text"}),e[16]||(e[16]=t("div",{class:"text-center"},[t("span",{class:"block text-card-text font-semibold text-base"},"Pushover"),t("span",{class:"text-xs text-card-text-secondary mt-1"},"Push notifications to your team's phones for the events you choose")],-1))]),t("button",{type:"button",class:"flex flex-col items-center gap-3 p-5 bg-card border border-[var(--admin-border)] rounded-lg hover:bg-card-button-subtle transition-colors text-left focus:outline-hidden focus-visible:ring-2 focus-visible:ring-admin-accent-ring",onClick:e[3]||(e[3]=s=>A("raw"))},[b(p,{name:"heroicons:code-bracket-20-solid",class:"w-8 h-8 text-card-text"}),e[17]||(e[17]=t("div",{class:"text-center"},[t("span",{class:"block text-card-text font-semibold text-base"},"Custom URL"),t("span",{class:"text-xs text-card-text-secondary mt-1"},"Raw JSON payload with HMAC-SHA256 signature verification")],-1))])])])]))]),_:1})}}});
1export{ft 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.