import{e as v,f as V}from"./chunk-TGUT5DGG.js";import{a as d,b as z}from"./chunk-SM7EQ7ST.js";import{c as m,d as j}from"./chunk-RWCAFOHA.js";import{Gk as f,Hk as y}from"./chunk-BPZQKZKD.js";import{b as S,c as w}from"./chunk-YBNTOQCK.js";import{Sa as I,be as M,ka as o,ta as l,x as t,xa as c}from"./chunk-WL5U2YIT.js";import{a,b as p,e as h}from"./chunk-ADEKKGI2.js";var u,A=h(()=>{u=class{constructor(i){this.subscriptionCount=0,this.subscriberCount=0,this.subscribers=[],this.subscriptions=[],i&&(this.id=i.id,this.name=i.name,this.subscribers=i.subscribers||[],this.subscriptions=i.subscriptions||[],this.subscriberCount=this.subscribers.length,this.subscriptionCount=this.subscriptions.length)}}});var O,x=h(()=>{z();I();A();M();w();j();V();y();O=(()=>{let i=class i extends d{constructor(s,e,r,b){super(s,e),this.subscriberFactoryService=r,this.assetServices=b}get(s){return this.assetServices.GetSubscriberGroup(s).pipe(o(e=>this.handleGetApiResult(e)),t(e=>this.returnWhenSuccessful(e,()=>this.normalizeSubscribersInGroup(e.data))))}getAll(){return this.assetServices.GetAllSubscriberGroups().pipe(o(s=>this.handleGetApiResult(s)),t(s=>this.returnWhenSuccessful(s,()=>this.normalizeSubscribersInGroups(s.data))))}getAllAsViewModel(){return this.getAll().pipe(t(s=>s?this.toViewModels(this.normalizeSubscribersInGroups(s)):null))}save(s){let e=this.toSaveModel(s);return this.assetServices.SaveSubscriberGroup(e).pipe(o(r=>this.handleSaveApiResult(r)),t(r=>this.returnWhenSuccessful(r,()=>r.data)))}delete(s){return this.assetServices.DeleteSubscriberGroup(s).pipe(o(e=>this.handleDeleteApiResult(e)),t(e=>this.isSuccessful(e)))}normalizeSubscribersInGroup(s){return p(a({},s),{subscribers:this.subscriberFactoryService.toSubscribers(s.subscribers)})}normalizeSubscribersInGroups(s){return(s||[]).map(e=>this.normalizeSubscribersInGroup(e))}toViewModel(s){return new u(s)}toViewModels(s){return(s||[]).map(e=>this.toViewModel(e))}toSaveModel(s){let e=(r,b,G)=>G.indexOf(r)===b;return p(a({},s),{subscribers:[],subscriptions:[],subscriberIds:s.subscriberIds.filter(e).filter(r=>!!r)})}};i.\u0275fac=function(e){return new(e||i)(c(S),c(m),c(v),c(f))},i.\u0275prov=l({token:i,factory:i.\u0275fac,providedIn:"root"});let n=i;return n})()});export{O as a,x as b};
