1import {q as qt,z as ze}from'./chunk-D-2o3j0p.js';import'./chunk-R_p-Vt0X.js';import {W as W$1}from'./chunk-CF84gehD.js';import {R}from'./chunk-BGOHF1M9.js';import {c as ce}from'./chunk-BRsHFk4j.js';import'./chunk-C0DmzTpz.js';import {W,dY as _,c3 as Xr,E,D,V,bK as P,bI as Gt,aE as ut,v as vr,e as f,b,O,X as Xb,j as Xv,R as RM,T as Tt,N as Ng,bv as Og,bN as Gc,z as zg,w as w0,b1 as ei,H as H0,Z as Zx,k as dn$1,b2 as da,cp as xr,l as zw,s as sk,n as nd,b3 as id,r as rC,m as wC,cV as fu,o as mv,p as GC,t as tD,q as vD,aO as cD,aP as hD,b0 as _D,aW as pD,aX as mD,u as al,x as tM,y as dM,L as Lb,A as r1,P as P1,B as xS,C as Vs,F as zs,I as Fi$1,J as GS,K as iI,M as RI,Q as us,S as ms,Y as UI,bT as GI,_ as tE,$ as Dn$1,a0 as ME,a1 as ny,a2 as go,a3 as Kd,av as on$1,a4 as XE,a5 as LT,a6 as mA,d_ as tA,d$ as nA,e0 as sA,e1 as aA,e2 as iA,e3 as lA,e4 as rA,e5 as oA,e6 as dA,e7 as cA,cx as WM,a7 as mt,a8 as fy,a9 as ZT,aa as Js,ac as H_,ad as gd,ae as pS,ab as Ey,bV as zy,bW as W_,af as XT,bD as db,ai as dy,bn as nS,ag as SC,ah as YT,ak as Ed,al as gS,aj as jy,bX as $y,bE as pb,am as JT,br as ht,co as Bg,b8 as an$1,b9 as Wm,bt as Lg,bu as Ts,bw as Pg,bM as Ic,bx as Gt$1,by as Jc,aL as co,bO as jh,da as wr,bP as Dh,bA as Nw,cS as ey,cT as iy,cU as ty,aT as d_,aR as i_,aS as Vp,aU as Hp,cE as vd,aB as ey$1,cF as Ea,aV as KT,ba as xy,bg as mS,aD as By}from'./main-4WA6AAHG.js';import {R as Ri$1}from'./chunk-D46YmFa5.js';import'./chunk-CkU8oUfw.js';var Le={FlowCompleted:"flow.completed"};var Fi=(e,l)=>l.key;function Bi(e,l){e&1&&(Js(0,"mat-error"),H_(1),pS(2,"translate"),gd()),e&2&&(SC(),jy(gS(2,1,"Please give this destination a name.")));}function Ai(e,l){e&1&&(Js(0,"mat-error"),H_(1),pS(2,"translate"),gd()),e&2&&(SC(),jy(gS(2,1,"Please enter the address of your server.")));}function Oi(e,l){e&1&&(Js(0,"mat-error"),H_(1),pS(2,"translate"),gd()),e&2&&(SC(),jy(gS(2,1,"The address must start with https:// \u2014 we do not send customer data over an unencrypted connection.")));}function Pi(e,l){if(e&1){let t=i_();Js(0,"mat-checkbox",15),Ey("change",function(a){let m=Vp(t).$implicit,x=d_();return Hp(x.toggleEvent(m.key,a.checked))}),H_(1),pS(2,"translate"),Js(3,"span",16),H_(4),gd()();}if(e&2){let t=l.$implicit,s=d_();dy("checked",s.isEventSelected(t.key)),SC(),Ed(" ",gS(2,3,t.label)," "),SC(3),Ed("(",t.key,")");}}function Li(e,l){e&1&&(Js(0,"div",9),H_(1),pS(2,"translate"),gd()),e&2&&(SC(),Ed(" ",gS(2,1,"Choose at least one event, otherwise nothing will ever be sent.")," "));}var jt=(()=>{class e{constructor(t,s,a,m,x,Be,M){this.fb=t,this.service=s,this.loadingService=a,this.errorService=m,this.toastr=x,this.dialogRef=Be,this.data=M,this.isEdit=false,this.isSaving=false,this.availableEvents=[{key:Le.FlowCompleted,label:"A customer submits a Flow"}],this.selectedEvents=new Set([Le.FlowCompleted]),this.isEdit=!!M?.endpoint,this.form=this.fb.group({name:[M?.endpoint?.name??"",[ht.required,ht.maxLength(200)]],url:[M?.endpoint?.url??"",[ht.required,ht.maxLength(1e3),ht.pattern(/^https:\/\/.+/i)]],isActive:[M?.endpoint?.isActive??true]}),M?.endpoint?.subscribedEvents&&(this.selectedEvents=new Set(M.endpoint.subscribedEvents.split(",").map(O=>O.trim()).filter(O=>!!O)));}toggleEvent(t,s){s?this.selectedEvents.add(t):this.selectedEvents.delete(t);}isEventSelected(t){return this.selectedEvents.has(t)}save(){if(this.form.invalid||this.selectedEvents.size===0){this.form.markAllAsTouched();return}let t=this.form.value;this.isSaving=true,this.loadingService.loadingOn(),this.service.upsertEndpoint({id:this.data?.endpoint?.id??null,name:t.name,url:t.url,subscribedEvents:Array.from(this.selectedEvents).join(","),isActive:t.isActive}).pipe(Xr(()=>{this.isSaving=false,this.loadingService.loadingOff();})).subscribe({next:s=>{s.succeeded?(this.toastr.success(this.isEdit?"Destination updated":"Destination added"),this.dialogRef.close(true)):this.errorService.setError(s,"Failed to save the webhook");},error:s=>this.errorService.setError(s,"Failed to save the webhook")});}cancel(){this.dialogRef.close(false);}static{this.\u0275fac=function(s){return new(s||e)(V(Bg),V(ze),V(P),V(Gt),V(ut),V(an$1),V(Wm))};}static{this.\u0275cmp=Xb({type:e,selectors:[["app-add-edit-webhook-dialog"]],decls:45,vars:36,consts:[["mat-dialog-title",""],[1,"m-r-4"],[3,"formGroup"],[1,"mat-subtitle-2","f-w-600","m-b-8","d-block"],["appearance","outline",1,"w-100"],["matInput","","formControlName","name","maxlength","200",3,"placeholder"],["matInput","","formControlName","url","placeholder","https://api.your-company.com/sociallab","maxlength","1000","dir","ltr"],[1,"m-t-24"],["color","primary",3,"checked"],[1,"f-s-12","m-t-8",2,"color","#b91c1c"],["color","primary","formControlName","isActive"],[1,"text-muted","f-s-12","m-t-4"],["align","end"],["mat-stroked-button","",3,"click"],["mat-flat-button","","color","primary",3,"click","disabled"],["color","primary",3,"change","checked"],[1,"text-muted","f-s-12","m-l-8"]],template:function(s,a){s&1&&(Js(0,"h2",0)(1,"mat-icon",1),H_(2,"webhook"),gd(),H_(3),pS(4,"translate"),gd(),Js(5,"mat-dialog-content")(6,"form",2)(7,"mat-label",3),H_(8),pS(9,"translate"),gd(),Js(10,"mat-form-field",4),fy(11,"input",5),pS(12,"translate"),db(),ZT(13,Bi,3,3,"mat-error"),gd(),Js(14,"mat-label",3),H_(15),pS(16,"translate"),gd(),Js(17,"mat-form-field",4),fy(18,"input",6),db(),Js(19,"mat-hint"),H_(20),pS(21,"translate"),gd(),ZT(22,Ai,3,3,"mat-error"),ZT(23,Oi,3,3,"mat-error"),gd(),Js(24,"div",7)(25,"mat-label",3),H_(26),pS(27,"translate"),gd(),XT(28,Pi,5,5,"mat-checkbox",8,Fi),ZT(30,Li,3,3,"div",9),gd(),Js(31,"div",7)(32,"mat-slide-toggle",10),H_(33),pS(34,"translate"),gd(),db(),Js(35,"div",11),H_(36),pS(37,"translate"),gd()()()(),Js(38,"mat-dialog-actions",12)(39,"button",13),Ey("click",function(){return a.cancel()}),H_(40),pS(41,"translate"),gd(),Js(42,"button",14),Ey("click",function(){return a.save()}),H_(43),pS(44,"translate"),gd()()),s&2&&(SC(3),Ed(" ",gS(4,16,a.isEdit?"Edit destination":"Add destination"),` 2`),SC(3),dy("formGroup",a.form),SC(2),Ed("",gS(9,18,"Name"),"*"),SC(3),dy("placeholder",gS(12,20,"For example: Our CRM")),pb(),SC(2),YT(a.form.controls.name.touched&&a.form.controls.name.hasError("required")?13:-1),SC(2),Ed("",gS(16,22,"Address (URL)"),"*"),SC(3),pb(),SC(2),jy(gS(21,24,"Must start with https. We will POST the event to this address as JSON.")),SC(2),YT(a.form.controls.url.touched&&a.form.controls.url.hasError("required")?22:-1),SC(),YT(a.form.controls.url.touched&&a.form.controls.url.hasError("pattern")?23:-1),SC(3),jy(gS(27,26,"Send this destination")),SC(2),JT(a.availableEvents),SC(2),YT(a.selectedEvents.size===0?30:-1),SC(2),pb(),SC(),Ed(" ",gS(34,28,"Sending is on")," "),SC(3),Ed(" ",gS(37,30,"Turn this off to pause everything to this destination without deleting it.")," "),SC(4),jy(gS(41,32,"Cancel")),SC(2),dy("disabled",a.isSaving),SC(),Ed(" ",gS(44,34,"Save")," "));},dependencies:[Xv,zg,Lg,Ts,Og,Pg,Ic,Gt$1,Jc,Tt,Ng,w0,co,H0,jh,Zx,dn$1,da,xr,wr,Dh,zw,Nw,sk,nd,rC,wC,fu,mv,GC,tD,vD,al,tM,dM,Lb,r1,P1,xS,Vs,zs,GS,iI,RI,us,ms,UI,tE,Dn$1,ME,ny,ey,iy,ty,go,Kd,XE,LT,mA,mt],encapsulation:2,changeDetection:1});}}return e})();var Ri=()=>["Add a destination \u2014 give it a name and the HTTPS address on your server that should receive the data.","Press Send test. Your server should answer 200. Anything else is shown here so you can fix it.","Open a Flow and choose this destination under Send results to.","Watch the Recent deliveries list below to confirm the real submissions arrive."],Ht=(e,l)=>l.id;function $i(e,l){if(e&1&&fy(0,"app-alert-message",1),e&2){let t=d_();dy("messages",t.featureAccessMessage)("dismissible",false);}}function Ni(e,l){e&1&&(Js(0,"div",7),fy(1,"mat-spinner",17),gd());}function Vi(e,l){if(e&1){let t=i_();Js(0,"app-empty-state",18),Ey("action",function(){Vp(t);let a=d_();return Hp(a.addEndpoint())}),gd();}if(e&2){let t=d_();dy("showAction",t.canUseFeature);}}function ji(e,l){e&1&&(Js(0,"span",25),H_(1),pS(2,"translate"),gd()),e&2&&(SC(),jy(gS(2,1,"Off")));}function Hi(e,l){e&1&&(Js(0,"span",25),H_(1),pS(2,"translate"),gd()),e&2&&(SC(),jy(gS(2,1,"Not used yet")));}function Ui(e,l){e&1&&(Js(0,"span",26),H_(1),pS(2,"translate"),gd()),e&2&&(SC(),jy(gS(2,1,"Working")));}function zi(e,l){e&1&&(Js(0,"span",27),H_(1),pS(2,"translate"),gd()),e&2&&(SC(),jy(gS(2,1,"Last delivery failed")));}function Gi(e,l){if(e&1&&(Js(0,"span",30),H_(1),gd()),e&2){let t=l.$implicit;SC(),jy(t);}}function qi(e,l){if(e&1&&(Js(0,"span"),H_(1),gd()),e&2){let t=d_(2).$implicit;SC(),Ed(" \xB7 HTTP ",t.lastDeliveryStatusCode);}}function Yi(e,l){if(e&1&&(Js(0,"span",31),H_(1),pS(2,"translate"),pS(3,"date"),ZT(4,qi,2,1,"span"),gd()),e&2){let t=d_().$implicit;SC(),By(" ",gS(2,3,"Last delivery"),": ",mS(3,5,t.lastDeliveryOn,"yyyy-MM-dd HH:mm")," "),SC(3),YT(t.lastDeliveryStatusCode?4:-1);}}function Ki(e,l){e&1&&(Js(0,"div",32)(1,"mat-icon",39),H_(2,"info"),gd(),Js(3,"span"),H_(4),pS(5,"translate"),gd()()),e&2&&(SC(4),jy(gS(5,1,"SocialLab turned this off automatically because deliveries kept failing. Fix your server, then switch it back on.")));}function Ji(e,l){e&1&&fy(0,"mat-spinner",36);}function Xi(e,l){e&1&&(Js(0,"mat-icon"),H_(1,"send"),gd());}function Qi(e,l){if(e&1){let t=i_();Js(0,"div",20)(1,"div",21)(2,"div",22),fy(3,"span",23),Js(4,"span",24),H_(5),gd(),ZT(6,ji,3,3,"span",25)(7,Hi,3,3,"span",25)(8,Ui,3,3,"span",26)(9,zi,3,3,"span",27),gd(),Js(10,"div",28),H_(11),gd(),Js(12,"div",29),XT(13,Gi,2,1,"span",30,KT),ZT(15,Yi,5,8,"span",31),gd(),ZT(16,Ki,6,3,"div",32),gd(),Js(17,"div",33)(18,"mat-slide-toggle",34),pS(19,"translate"),Ey("change",function(a){let m=Vp(t).$implicit,x=d_(2);return Hp(x.toggleActive(m,a.checked))}),gd(),Js(20,"button",35),Ey("click",function(){let a=Vp(t).$implicit,m=d_(2);return Hp(m.sendTest(a))}),ZT(21,Ji,1,0,"mat-spinner",36)(22,Xi,2,0,"mat-icon"),H_(23),pS(24,"translate"),gd(),Js(25,"button",37),pS(26,"translate"),Ey("click",function(){let a=Vp(t).$implicit,m=d_(2);return Hp(m.editEndpoint(a))}),Js(27,"mat-icon"),H_(28,"edit"),gd()(),Js(29,"button",38),pS(30,"translate"),Ey("click",function(){let a=Vp(t).$implicit,m=d_(2);return Hp(m.deleteEndpoint(a))}),Js(31,"mat-icon"),H_(32,"delete"),gd()()()();}if(e&2){let t,s=l.$implicit,a=d_(2);xy("is-inactive",!s.isActive),SC(3),dy("ngClass","health-"+a.healthOf(s)),SC(2),jy(s.name),SC(),YT((t=a.healthOf(s))==="inactive"?6:t==="unknown"?7:t==="healthy"?8:t==="failing"?9:-1),SC(5),jy(s.url),SC(2),JT(a.eventsOf(s)),SC(2),YT(s.lastDeliveryOn?15:-1),SC(),YT(s.disabledReason?16:-1),SC(2),dy("checked",s.isActive)("disabled",!a.canUseFeature)("matTooltip",gS(19,18,"Turn sending on or off")),SC(2),dy("disabled",!a.canUseFeature||a.testingEndpointId===s.id),SC(),YT(a.testingEndpointId===s.id?21:22),SC(2),Ed(" ",gS(24,20,"Send test")," "),SC(2),dy("disabled",!a.canUseFeature)("matTooltip",gS(26,22,"Edit")),SC(4),dy("disabled",!a.canUseFeature)("matTooltip",gS(30,24,"Delete"));}}function Zi(e,l){if(e&1&&(Js(0,"div",9),XT(1,Qi,33,26,"div",19,Ht),gd()),e&2){let t=d_();SC(),JT(t.endpoints);}}function en(e,l){if(e&1&&(Js(0,"mat-option",13),H_(1),gd()),e&2){let t=l.$implicit;dy("value",t.id),SC(),jy(t.name);}}function tn(e,l){e&1&&(Js(0,"div",7),fy(1,"mat-spinner",17),gd());}function nn(e,l){e&1&&fy(0,"app-empty-state",15);}function on(e,l){e&1&&(Js(0,"th",52),H_(1),pS(2,"translate"),gd()),e&2&&(SC(),jy(gS(2,1,"Result")));}function an(e,l){if(e&1&&(Js(0,"span"),H_(1),gd()),e&2){let t=d_(2).$implicit;SC(),Ed(" \xB7 ",t.responseStatusCode);}}function rn(e,l){if(e&1&&(Js(0,"span",26),H_(1),pS(2,"translate"),ZT(3,an,2,1,"span"),gd()),e&2){let t=d_().$implicit;SC(),Ed(" ",gS(2,2,"Webhook delivered")),SC(2),YT(t.responseStatusCode?3:-1);}}function ln(e,l){if(e&1&&H_(0),e&2){let t=d_(2).$implicit;Ed(" HTTP ",t.responseStatusCode," ");}}function sn(e,l){e&1&&(H_(0),pS(1,"translate")),e&2&&Ed(" ",gS(1,1,"No response")," ");}function dn(e,l){if(e&1&&(Js(0,"span",27),ZT(1,ln,1,1)(2,sn,2,3),gd()),e&2){let t=d_().$implicit;SC(),YT(t.responseStatusCode?1:2);}}function pn(e,l){if(e&1&&(Js(0,"td",53),ZT(1,rn,4,4,"span",26)(2,dn,3,1,"span",27),gd()),e&2){let t=l.$implicit;SC(),YT(t.isSuccess?1:2);}}function mn(e,l){e&1&&(Js(0,"th",52),H_(1),pS(2,"translate"),gd()),e&2&&(SC(),jy(gS(2,1,"Event")));}function cn(e,l){if(e&1&&(Js(0,"td",53)(1,"span",30),H_(2),gd()()),e&2){let t=l.$implicit;SC(2),jy(t.eventType);}}function un(e,l){e&1&&(Js(0,"th",52),H_(1),pS(2,"translate"),gd()),e&2&&(SC(),jy(gS(2,1,"Destination")));}function hn(e,l){if(e&1&&(Js(0,"td",53),H_(1),gd()),e&2){let t=l.$implicit;SC(),jy(t.endpointName);}}function _n(e,l){e&1&&(Js(0,"th",52),H_(1),pS(2,"translate"),gd()),e&2&&(SC(),jy(gS(2,1,"Attempt")));}function fn(e,l){if(e&1&&(Js(0,"span",54),pS(1,"translate"),H_(2),gd()),e&2){let t=d_().$implicit;dy("matTooltip",gS(1,2,"This was a retry after an earlier attempt failed")),SC(2),Ed(" ",t.attemptNumber," ");}}function vn(e,l){if(e&1&&H_(0),e&2){let t=d_().$implicit;Ed(" ",t.attemptNumber," ");}}function Cn(e,l){if(e&1&&(Js(0,"td",53),ZT(1,fn,3,4,"span",54)(2,vn,1,1),gd()),e&2){let t=l.$implicit;SC(),YT(t.attemptNumber>1?1:2);}}function gn(e,l){e&1&&(Js(0,"th",52),H_(1),pS(2,"translate"),gd()),e&2&&(SC(),jy(gS(2,1,"Time taken")));}function bn(e,l){if(e&1&&H_(0),e&2){let t=d_().$implicit;Ed(" ",t.durationMs," ms ");}}function xn(e,l){e&1&&H_(0," \u2014 ");}function Mn(e,l){if(e&1&&(Js(0,"td",53),ZT(1,bn,1,1)(2,xn,1,0),gd()),e&2){let t=l.$implicit;SC(),YT(t.durationMs!==null&&t.durationMs!==void 0?1:2);}}function Sn(e,l){e&1&&(Js(0,"th",52),H_(1),pS(2,"translate"),gd()),e&2&&(SC(),jy(gS(2,1,"When")));}function En(e,l){if(e&1&&(Js(0,"td",53),H_(1),pS(2,"date"),gd()),e&2){let t=l.$implicit;SC(),jy(mS(2,1,t.createdOn,"yyyy-MM-dd HH:mm:ss"));}}function kn(e,l){e&1&&fy(0,"th",52);}function yn(e,l){if(e&1){let t=i_();Js(0,"td",53)(1,"button",14),pS(2,"translate"),Ey("click",function(){let a=Vp(t).$implicit,m=d_(2);return Hp(m.viewDelivery(a))}),Js(3,"mat-icon"),H_(4,"visibility"),gd()()();}e&2&&(SC(),dy("matTooltip",gS(2,1,"View details")));}function Tn(e,l){e&1&&fy(0,"tr",55);}function wn(e,l){e&1&&fy(0,"tr",56);}function Dn(e,l){if(e&1&&(Js(0,"div",16)(1,"table",40),vd(2,41),ey$1(3,on,3,3,"th",42)(4,pn,3,1,"td",43),Ea(),vd(5,44),ey$1(6,mn,3,3,"th",42)(7,cn,3,1,"td",43),Ea(),vd(8,45),ey$1(9,un,3,3,"th",42)(10,hn,2,1,"td",43),Ea(),vd(11,46),ey$1(12,_n,3,3,"th",42)(13,Cn,3,1,"td",43),Ea(),vd(14,47),ey$1(15,gn,3,3,"th",42)(16,Mn,3,1,"td",43),Ea(),vd(17,48),ey$1(18,Sn,3,3,"th",42)(19,En,3,4,"td",43),Ea(),vd(20,49),ey$1(21,kn,1,0,"th",42)(22,yn,5,3,"td",43),Ea(),ey$1(23,Tn,1,0,"tr",50)(24,wn,1,0,"tr",51),gd()()),e&2){let t=d_();SC(),dy("dataSource",t.deliveries),SC(22),dy("matHeaderRowDef",t.deliveryColumns),SC(),dy("matRowDefColumns",t.deliveryColumns);}}var io=(()=>{class e{constructor(t,s,a,m,x,Be,M,O){this.service=t,this.loadingService=s,this.errorService=a,this.toastr=m,this.dialog=x,this.dialogConfigService=Be,this.clientsService=M,this.translate=O,this.sub=new W,this.endpoints=[],this.deliveries=[],this.isLoadingEndpoints=false,this.isLoadingDeliveries=false,this.deliveryFilterEndpointId=null,this.testingEndpointId=null,this.canUseFeature=true,this.featureAccessMessage=[],this.deliveryColumns=["status","event","endpoint","attempt","duration","when","actions"];}ngOnInit(){this.checkFeatureAccess(),this.loadEndpoints(),this.loadDeliveries();}ngOnDestroy(){this.sub.unsubscribe();}checkFeatureAccess(){this.clientsService.canUseFeature(_.PARTNER_API).subscribe({next:t=>{this.canUseFeature=t,t||(this.featureAccessMessage=[this.translate.instant("You either don't have a subscription or your subscription does not support this feature or you have reached the maximum limit.")]);},error:()=>{this.canUseFeature=false;}});}loadEndpoints(){this.isLoadingEndpoints=true,this.loadingService.beginSuppress(),this.sub.add(this.service.getEndpoints().pipe(Xr(()=>{this.isLoadingEndpoints=false,this.loadingService.endSuppress();})).subscribe({next:t=>{t.succeeded?this.endpoints=t.data??[]:this.errorService.setError(t,"Error while getting the data");},error:t=>this.errorService.setError(t,"Error while getting the data")}));}addEndpoint(){this.openEndpointDialog(null);}editEndpoint(t){this.openEndpointDialog(t);}openEndpointDialog(t){let s=this.dialogConfigService.getDefaultDialogConfig();this.dialog.open(jt,E(D({},s),{data:{endpoint:t}})).afterClosed().subscribe(m=>{m&&this.loadEndpoints(
2);});}toggleActive(t,s){this.loadingService.loadingOn(),this.sub.add(this.service.upsertEndpoint({id:t.id,name:t.name,url:t.url,subscribedEvents:t.subscribedEvents,isActive:s}).pipe(Xr(()=>this.loadingService.loadingOff())).subscribe({next:a=>{a.succeeded?(this.toastr.success(s?"Webhook enabled":"Webhook disabled"),this.loadEndpoints()):(this.errorService.setError(a,"Failed to save the webhook"),this.loadEndpoints());},error:a=>{this.errorService.setError(a,"Failed to save the webhook"),this.loadEndpoints();}}));}deleteEndpoint(t){this.dialog.open(Ri$1,{width:"420px"}).afterClosed().subscribe(a=>{a&&(this.loadingService.loadingOn(),this.sub.add(this.service.deleteEndpoint(t.id).pipe(Xr(()=>this.loadingService.loadingOff())).subscribe({next:m=>{m.succeeded?(this.toastr.success("Webhook deleted"),this.loadEndpoints(),this.loadDeliveries()):this.errorService.setError(m,"Failed to delete the webhook");},error:m=>this.errorService.setError(m,"Failed to delete the webhook")})));});}sendTest(t){this.testingEndpointId=t.
2id,this.loadingService.beginSuppress(),this.sub.add(this.service.sendTest(t.id).pipe(Xr(()=>{this.testingEndpointId=null,this.loadingService.endSuppress();})).subscribe({next:s=>{if(!s.succeeded){this.errorService.setError(s,"Failed to send the test");return}let a=s.data;if(a?.success)this.toastr.success("Test delivered successfully");else {let m=a?.statusCode?`HTTP ${a.statusCode}`:a?.error??this.translate.instant("No response");this.toastr.error(`${this.translate.instant("Test delivery failed")}: ${m}`);}this.loadDeliveries();},error:s=>this.errorService.setError(s,"Failed to send the test")}));}loadDeliveries(){this.isLoadingDeliveries=true,this.loadingService.beginSuppress(),this.sub.add(this.service.getDeliveries(this.deliveryFilterEndpointId,100).pipe(Xr(()=>{this.isLoadingDeliveries=false,this.loadingService.endSuppress();})).subscribe({next:t=>{t.succeeded?this.deliveries=t.data??[]:this.errorService.setError(t,"Error while getting the data");},error:t=>this.errorService.setError(t,"Error while getting the data")}));}onDeliveryFilterChange(){this.loadDeliveries();}viewDelivery(t){let s=this.dialogConfigService.getDefaultDialogConfig();this.dialog.open(qt,E(D({},s),{width:"760px",data:{delivery:t}}));}eventsOf(t){return (t.subscribedEvents??"").split(",").map(s=>s.trim()).filter(s=>!!s)}healthOf(t){return t.isActive?t.lastDeliverySucceeded===null||t.lastDeliverySucceeded===void 0?"unknown":t.lastDeliverySucceeded?"healthy":"failing":"inactive"}static{this.\u0275fac=function(s){return new(s||e)(V(ze),V(P),V(Gt),V(ut),V(vr),V(f),V(b),V(O))};}static{this.\u0275cmp=Xb({type:e,selectors:[["app-webhooks"]],decls:51,vars:32,consts:[["helpKey","webhooks","intro","Send what happens in SocialLab straight to your own system. Today that means WhatsApp Flow submissions: the moment a customer submits a form, we POST it to your URL.","warning","Every request is signed with your Partner API key. Verify the X-SocialLab-Signature header before trusting the data \u2014 otherwise anyone who learns your URL can send you fake submissions.",3,"steps"],["type","warning",3,"messages","dismissible"],[1,"cardWithShadow","theme-card"],[1,"m-r-4"],[1,"header-spacer"],["mat-flat-button","","color","primary",3,"click","disabled"],[1,"b-t-1","m-t-16"],[1,"text-center","p-y-32"],["icon","webhook","title","No destinations yet","message","Add the address of your server and SocialLab will start sending your Flow results to it.","actionLabel","Add destination",3,"showAction"],[1,"endpoint-list"],[1,"cardWithShadow","theme-card","m-t-24"],["appearance","outline","subscriptSizing","dynamic",1,"filter-field"],[3,"ngModelChange","selectionChange","ngModel"],[3,"value"],["mat-icon-button","",3,"click","matTooltip"],["icon","inbox","title","Nothing sent yet","message","Once a customer submits a Flow that points at one of your destinations, the attempt shows up here.","size","small"],[1,"table-responsive"],["diameter","36",2,"display","inline-block"],["icon","webhook","title","No destinations yet","message","Add the address of your server and SocialLab will start sending your Flow results to it.","actionLabel","Add destination",3,"action","showAction"],[1,"endpoint-row",3,"is-inactive"],[1,"endpoint-row"],[1,"endpoint-main"],[1,"d-flex","align-items-center","gap-8","m-b-4"],[1,"health-dot",3,"ngClass"],[1,"f-w-600","f-s-16"],[1,"status-pill","pill-muted"],[1,"status-pill","pill-ok"],[1,"status-pill","pill-bad"],[1,"endpoint-url","text-muted","f-s-13"],[1,"d-flex","align-items-center","flex-wrap","gap-8","m-t-8"],[1,"event-chip"],[1,"text-muted","f-s-12"],[1,"disabled-note","m-t-8"],[1,"endpoint-actions"],["color","primary",3,"change","checked","disabled","matTooltip"],["mat-stroked-button","",3,"click","disabled"],["diameter","16",2,"display","inline-block"],["mat-icon-button","",3,"click","disabled","matTooltip"],["mat-icon-button","","color","warn",3,"click","disabled","matTooltip"],[1,"f-s-16"],["mat-table","",1,"w-100",3,"dataSource"],["matColumnDef","status"],["mat-header-cell","",4,"matHeaderCellDef"],["mat-cell","",4,"matCellDef"],["matColumnDef","event"],["matColumnDef","endpoint"],["matColumnDef","attempt"],["matColumnDef","duration"],["matColumnDef","when"],["matColumnDef","actions"],["mat-header-row","",4,"matHeaderRowDef"],["mat-row","",4,"matRowDef","matRowDefColumns"],["mat-header-cell",""],["mat-cell",""],[3,"matTooltip"],["mat-header-row",""],["mat-row",""]],template:function(s,a){s&1&&(fy(0,"app-page-help",0),ZT(1,$i,1,2,"app-alert-message",1),Js(2,"mat-card",2)(3,"mat-card-header")(4,"mat-card-title")(5,"mat-icon",3),H_(6,"webhook"),gd(),H_(7),pS(8,"translate"),gd(),Js(9,"mat-card-subtitle"),H_(10),pS(11,"translate"),gd(),fy(12,"span",4),Js(13,"button",5),Ey("click",function(){return a.addEndpoint()}),Js(14,"mat-icon"),H_(15,"add"),gd(),H_(16),pS(17,"translate"),gd()(),Js(18,"mat-card-content",6),ZT(19,Ni,2,0,"div",7)(20,Vi,1,1,"app-empty-state",8)(21,Zi,3,0,"div",9),gd()(),Js(22,"mat-card",10)(23,"mat-card-header")(24,"mat-card-title")(25,"mat-icon",3),H_(26,"history"),gd(),H_(27),pS(28,"translate"),gd(),Js(29,"mat-card-subtitle"),H_(30),pS(31,"translate"),gd(),fy(32,"span",4),Js(33,"mat-form-field",11)(34,"mat-label"),H_(35),pS(36,"translate"),gd(),Js(37,"mat-select",12),zy("ngModelChange",function(x){return W_(a.deliveryFilterEndpointId,x)||(a.deliveryFilterEndpointId=x),x}),Ey("selectionChange",function(){return a.onDeliveryFilterChange()}),Js(38,"mat-option",13),H_(39),pS(40,"translate"),gd(),XT(41,en,2,2,"mat-option",13,Ht),gd(),db(),gd(),Js(43,"button",14),pS(44,"translate"),Ey("click",function(){return a.loadDeliveries()}),Js(45,"mat-icon"),H_(46,"refresh"),gd()()(),Js(47,"mat-card-content",6),ZT(48,tn,2,0,"div",7)(49,nn,1,0,"app-empty-state",15)(50,Dn,25,3,"div",16),gd()()),s&2&&(dy("steps",nS(31,Ri)),SC(),YT(a.canUseFeature?-1:1),SC(6),Ed(" ",gS(8,15,"Webhook de
2stinations")," "),SC(3),jy(gS(11,17,"Addresses on your own servers that SocialLab sends events to.")),SC(3),dy("disabled",!a.canUseFeature),SC(3),Ed(" ",gS(17,19,"Add destination")," "),SC(3),YT(a.isLoadingEndpoints?19:a.endpoints.length===0?20:21),SC(8),Ed(" ",gS(28,21,"Recent deliveries")," "),SC(3),jy(gS(31,23,"The 100 most recent attempts. The log keeps 7 days.")),SC(5),jy(gS(36,25,"Destination")),SC(2),$y("ngModel",a.deliveryFilterEndpointId),pb(),SC(),dy("value",null),SC(),jy(gS(40,27,"All destinations")),SC(2),JT(a.endpoints),SC(2),dy("matTooltip",gS(44,29,"Refresh")),SC(5),YT(a.isLoadingDeliveries?48:a.deliveries.length===0?49:50));},dependencies:[ce,Xv,RM,Tt,W$1,R,Ng,Og,Gc,zg,w0,ei,H0,Zx,dn$1,da,xr,zw,sk,nd,id,rC,wC,fu,mv,GC,tD,vD,cD,hD,_D,pD,mD,al,tM,dM,Lb,r1,P1,xS,Vs,zs,Fi$1,GS,iI,RI,us,ms,UI,GI,tE,Dn$1,ME,ny,go,Kd,on$1,XE,LT,mA,tA,nA,sA,aA,iA,lA,rA,oA,dA,cA,WM,mt],styles:['@charset "UTF-8";.endpoint-list[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:12px}.endpoint-row[_ngcontent-%COMP%]{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;padding:16px;border:1px solid var(--mat-sys-outline-variant, rgba(0, 0, 0, .12));border-radius:10px;transition:background-color .15s ease}.endpoint-row[_ngcontent-%COMP%]:hover{background-color:var(--mat-sys-surface-container-low, rgba(0, 0, 0, .02))}.endpoint-row.is-inactive[_ngcontent-%COMP%] .endpoint-main[_ngcontent-%COMP%]{opacity:.62}.endpoint-main[_ngcontent-%COMP%]{min-width:0;flex:1}.endpoint-url[_ngcontent-%COMP%]{word-break:break-all}.endpoint-actions[_ngcontent-%COMP%]{display:flex;align-items:center;gap:8px;flex-shrink:0;flex-wrap:wrap;justify-content:flex-end}.health-dot[_ngcontent-%COMP%]{width:9px;height:9px;border-radius:50%;flex-shrink:0;display:inline-block}.health-dot.health-healthy[_ngcontent-%COMP%]{background-color:#22c55e}.health-dot.health-failing[_ngcontent-%COMP%]{background-color:#ef4444}.health-dot.health-inactive[_ngcontent-%COMP%], .health-dot.health-unknown[_ngcontent-%COMP%]{background-color:#9ca3af}.status-pill[_ngcontent-%COMP%]{display:inline-block;padding:2px 10px;border-radius:999px;font-size:12px;font-weight:600;white-space:nowrap}.status-pill.pill-ok[_ngcontent-%COMP%]{background-color:#22c55e24;color:#15803d}.status-pill.pill-bad[_ngcontent-%COMP%]{background-color:#ef444424;color:#b91c1c}.status-pill.pill-muted[_ngcontent-%COMP%]{background-color:#9ca3af2e;color:#4b5563}.event-chip[_ngcontent-%COMP%]{display:inline-block;padding:2px 8px;border-radius:6px;font-family:Courier New,monospace;font-size:12px;background-color:var(--mat-sys-surface-container, rgba(0, 0, 0, .05));direction:ltr;unicode-bidi:embed}.disabled-note[_ngcontent-%COMP%]{display:flex;align-items:flex-start;gap:6px;font-size:12.5px;color:#b45309}.header-spacer[_ngcontent-%COMP%]{flex:1 1 auto}.filter-field[_ngcontent-%COMP%]{width:220px;margin-inline-end:8px}.table-responsive[_ngcontent-%COMP%]{overflow-x:auto}.gap-8[_ngcontent-%COMP%]{gap:8px}@media(max-width:767px){.endpoint-row[_ngcontent-%COMP%]{flex-direction:column}.endpoint-actions[_ngcontent-%COMP%]{justify-content:flex-start;width:100%}.filter-field[_ngcontent-%COMP%]{width:100%;margin-inline-end:0}}'],changeDetection:1});}}return e})();export{io as WebhooksComponent};
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.