1import{a as De}from"./chunk-EFL3OWM5.js";import{a as Ie}from"./chunk-N3CKHEE7.js";import{a as nt}from"./chunk-TXA554CQ.js";import{a as be,b as Se,c as xe,d as Te,e as ye,g as Ee,h as we,i as Me}from"./chunk-TXIW6DEW.js";import{a as Dt,b as Ut,d as ze}from"./chunk-WZUCEZF2.js";import{a as Ve}from"./chunk-DVPG56P6.js";import{a as _e,c as fe,d as he,e as Ce,f as ve}from"./chunk-E6EXZCAJ.js";import{a as Rt}from"./chunk-BROQV66G.js";import"./chunk-2KYBFJ6D.js";import{a as ke}from"./chunk-C43K3YJP.js";import{b as yt}from"./chunk-PIFK5PAS.js";import{b as Oe,c as Pe,d as Yt,e as Jt,f as Y}from"./chunk-3IE6ZIJT.js";import"./chunk-GURR5BWY.js";import"./chunk-4OODM5RZ.js";import{a as Ne}from"./chunk-HDN3V3OA.js";import"./chunk-25BZAPPZ.js";import"./chunk-YNY5VX5O.js";import{b as $}from"./chunk-B25OOK5G.js";import{a as T}from"./chunk-T4Z57YFC.js";import{a as L}from"./chunk-CZVPOIDA.js";import{a as et}from"./chunk-HKROCZZ5.js";import{c as Ae,d as Wt}from"./chunk-4TDVVZWI.js";import{a as Lt,b as Bt}from"./chunk-JV7BJH73.js";import"./chunk-PAWXXTXM.js";import{b as Tt,e as Fe}from"./chunk-LM52PLPW.js";import{a as $t,ub as tt}from"./chunk-ZMRJTPMN.js";import"./chunk-SYZ4TT7R.js";import"./chunk-4KE2SNJZ.js";import{b as j}from"./chunk-LOPWR4IF.js";import{a as W}from"./chunk-ERB4A4K4.js";import{B as me,C as zt,D as kt,E as de,I as ue,K as ge,L as bt,M as St,c as rt,e as Mt,f as Pt,h as Z,i as st,l as ut,m as mt,o as ht,p as lt,q as At,w as Ct,x as vt}from"./chunk-L72XHRI4.js";import{a as re}from"./chunk-QJGDHPIL.js";import{c as pe}from"./chunk-5YER4OD3.js";import{a as xt}from"./chunk-XQKA5YTI.js";import{a as at}from"./chunk-45XGHXLO.js";import{c as R,d as I,e as V,g as F}from"./chunk-OK4ZBCSP.js";import{f as ce}from"./chunk-QYTBOKNQ.js";import{l as D,s as se,t as Ot,w as le,x as U}from"./chunk-JRV2IVKS.js";import{Ad as jt,Ea as d,Ec as y,F as ie,Fa as u,Ga as qt,Ka as ft,Kb as wt,Ma as Et,Mc as h,Oc as p,Rb as E,Sc as H,Tc as G,Uc as K,Yb as pt,Yc as Q,_c as ae,ad as Ht,bd as l,cd as O,dd as w,ed as Vt,hd as z,id as k,jd as B,kd as q,lc as g,mc as _,nd as Ft,oc as ot,od as M,pc as P,pd as X,qc as A,qd as Nt,rc as m,sc as a,ta as _t,tc as o,uc as C,wd as b,xd as S,ya as f,yd as Qt,zb as s,zd as oe}from"./chunk-X2XUJWBI.js";import{h as Kt}from"./chunk-ZUU3DWDH.js";var en=(i,c)=>c.id;function nn(i,c){i&1&&C(0,"ab-loading-spinner",4),i&2&&m("absolute",!1)}function an(i,c){if(i&1&&(a(0,"tr")(1,"td"),l(2),o(),a(3,"td"),l(4),o(),a(5,"td"),l(6),o(),a(7,"td"),l(8),b(9,"translate"),o()()),i&2){let t=c.$implicit;s(2),w(" ",t.type," "),s(2),w(" ",t.name," "),s(2),w(" ",t.location," "),s(2),w(" ",S(9,4,t.category)," ")}}function on(i,c){if(i&1){let t=y();a(0,"div",1)(1,"div",5)(2,"div",6)(3,"table",7)(4,"thead")(5,"tr")(6,"th",8),h("sort",function(e){d(t);let r=p(2);return u(r.onSort(e))}),a(7,"span",9),l(8,"Display name"),o()(),a(9,"th",10),h("sort",function(e){d(t);let r=p(2);return u(r.onSort(e))}),a(10,"span",9),l(11,"Name"),o()(),a(12,"th",11),h("sort",function(e){d(t);let r=p(2);return u(r.onSort(e))}),a(13,"span",9),l(14,"Location"),o()(),a(15,"th",12),h("sort",function(e){d(t);let r=p(2);return u(r.onSort(e))}),a(16,"span",9),l(17,"Category"),o()()()(),a(18,"tbody"),P(19,an,10,6,"tr",null,en),o()()()()()}if(i&2){let t=p(2);s(19),A(t.machines)}}function rn(i,c){if(i&1&&(a(0,"div",0)(1,"div",1)(2,"div",2),C(3,"app-admin-config-page-header",3),b(4,"translate"),b(5,"translate"),b(6,"translate"),o()(),g(7,nn,1,1,"ab-loading-spinner",4),g(8,on,21,0,"div",1),o()),i&2){let t=p();s(3),m("heading",S(4,6,"Organization"))("itemName",t.tenant?t.tenant.name:"")("count",t.machines?t.machines.length:0)("type",t.machines&&t.machines.length===1?S(5,8,"Asset"):S(6,10,"Assets")),s(4),_(!t.tenant||!t.machines?7:-1),s(),_(t.tenant&&t.machines?8:-1)}}var Ue=(()=>{class i{constructor(){this.tableSortService=f(et),this.toastService=f(W),this.adminTenantService=f(Y),this.translateService=f(R),this.route=f(Tt),this.tenantId=-1}ngOnInit(){this.route.paramMap.subscribe(t=>{let n=t.get("tenantId");n&&(this.tenantId=parseInt(n),this.loadTenantMachines())})}onSort({column:t,direction:n}){this.headers&&this.tableSortService.sortTableItems(this.machines,t,n,this.headers)}loadTenantMachines(){this.tenantId&&this.adminTenantService.getMachines(this.tenantId).subscribe({next:t=>{this.machines=t,setTimeout(()=>{this.tableSortService.initialSortTableItems(this.machines,"type","asc",this.headers)})},error:()=>{this.toastService.error(this.translateService.instant("The machines could not be loaded!"))}})}static{this.\u0275fac=function(n){return new(n||i)}}static{this.\u0275cmp=E({type:i,selectors:[["app-organization-machines"]],viewQuery:function(n,e){if(n&1&&H(L,5),n&2){let r;G(r=K())&&(e.headers=r)}},inputs:{tenant:"tenant"},decls:1,vars:1,consts:[[1,"container-fluid"],[1,"row"],[1,"col-12"],[3,"heading","itemName","count","type"],[3,"absolute"],[1,"col"],[1,"table-responsive"],[1,"table","table-striped"],["sortable","type",1,"sortable",3,"sort"],["translate",""],["sortable","name",1,"sortable",3,"sort"],["sortable","location",1,"s
1ortable",3,"sort"],["sortable","category",1,"sortable",3,"sort"]],template:function(n,e){n&1&&g(0,rn,9,12,"div",0),n&2&&_(e.tenantId&&e.tenant?0:-1)},dependencies:[F,I,nt,$,L,V],encapsulation:2})}}return i})();var sn=(i,c)=>c.id;function ln(i,c){i&1&&C(0,"ab-loading-spinner",4),i&2&&m("absolute",!1)}function cn(i,c){i&1&&(a(0,"span",11),b(1,"translate"),qt(),a(2,"svg",14),C(3,"circle",15),o()()),i&2&&m("title",q(S(1,2,"End user agreement accepted")))}function pn(i,c){i&1&&(a(0,"span",12),b(1,"translate"),qt(),a(2,"svg",14),C(3,"circle",15),o()()),i&2&&m("title",q(S(1,2,"End user agreement NOT accepted")))}function mn(i,c){if(i&1&&(a(0,"del",13),b(1,"translate"),l(2),o()),i&2){let t=p().$implicit;m("title",q(S(1,3,"User banned."))),s(2),O(t.displayName)}}function dn(i,c){if(i&1&&(a(0,"span"),l(1),o()),i&2){let t=p().$implicit;s(),O(t.displayName)}}function un(i,c){if(i&1&&(a(0,"tr")(1,"td"),g(2,cn,4,4,"span",11),g(3,pn,4,4,"span",12),g(4,mn,3,5,"del",13),g(5,dn,2,1,"span"),o(),a(6,"td"),l(7),o()()),i&2){let t=c.$implicit;s(2),_(t.agreementAccepted?2:-1),s(),_(t.agreementAccepted?-1:3),s(),_(t.banned?4:-1),s(),_(t.banned?-1:5),s(2),w(" ",t.username," ")}}function gn(i,c){if(i&1){let t=y();a(0,"div",1)(1,"div",5)(2,"div",6)(3,"table",7)(4,"thead")(5,"tr")(6,"th",8),h("sort",function(e){d(t);let r=p();return u(r.onSort(e))}),a(7,"span",9),l(8,"Display name"),o()(),a(9,"th",10),h("sort",function(e){d(t);let r=p();return u(r.onSort(e))}),a(10,"span",9),l(11,"Name"),o()()()(),a(12,"tbody"),P(13,un,8,5,"tr",null,sn),o()()()()()}if(i&2){let t=p();s(13),A(t.users)}}var Le=(()=>{class i{constructor(){this.tableSortService=f(et),this.toastService=f(W),this.adminTenantService=f(Y),this.translateService=f(R)}ngOnInit(){this.loadTenantUsers()}onSort({column:t,direction:n}){this.headers&&this.tableSortService.sortTableItems(this.users,t,n,this.headers)}loadTenantUsers(){this.tenant&&this.adminTenantService.getUsers(this.tenant.id).subscribe({next:t=>{this.users=t,setTimeout(()=>{this.tableSortService.initialSortTableItems(t,"displayName","asc",this.headers)})},error:()=>{this.toastService.error(this.translateService.instant("The users could not be loaded!"))}})}static{this.\u0275fac=function(n){return new(n||i)}}static{this.\u0275cmp=E({type:i,selectors:[["app-organization-users"]],viewQuery:function(n,e){if(n&1&&H(L,5),n&2){let r;G(r=K())&&(e.headers=r)}},inputs:{tenant:"tenant"},decls:9,vars:12,consts:[[1,"container-fluid"],[1,"row"],[1,"col-12"],[3,"heading","itemName","count","type"],[3,"absolute"],[1,"col"],[1,"table-responsive"],[1,"table","table-striped"],["sortable","displayName",1,"sortable",3,"sort"],["translate",""],["sortable","username",1,"sortable",3,"sort"],[1,"text-success",3,"title"],[1,"text-danger",3,"title"],[3,"title"],["xmlns","http://www.w3.org/2000/svg","width","16","height","16","fill","currentColor","viewBox","0 0 16 16",1,"bi","bi-circle-fill"],["cx","6","cy","6","r","6"]],template:function(n,e){n&1&&(a(0,"div",0)(1,"div",1)(2,"div",2),C(3,"app-admin-config-page-header",3),b(4,"translate"),b(5,"translate"),b(6,"translate"),o()(),g(7,ln,1,1,"ab-loading-spinner",4),g(8,gn,15,0,"div",1),o()),n&2&&(s(3),m("heading",S(4,6,"Organization"))("itemName",e.tenant?e.tenant.name:"")("count",e.users?e.users.length:0)("type",e.users&&e.users.length===1?S(5,8,"User"):S(6,10,"Users")),s(4),_(!e.tenant||!e.users?7:-1),s(),_(e.tenant&&e.users?8:-1))},dependencies:[F,I,nt,$,L,V],encapsulation:2})}}return i})();var Gt=i=>({"is-invalid":i});function _n(i,c){i&1&&(a(0,"span",15),l(1,"Support contact department required"),o())}function fn(i,c){i&1&&(a(0,"span",15),l(1,"Support contact name required"),o())}function hn(i,c){i&1&&(a(0,"span",15),l(1,"E-mail address invalid"),o())}function Cn(i,c){i&1&&(a(0,"span",15),l(1,"Support contact email required"),o())}function vn(i,c){i&1&&(a(0,"span",15),l(1,"Support contact phone required"),o())}var Be=(()=>{class i{constructor(){this.contact=new Oe(void 0),this.activeModal=f(Lt)}ngOnInit(){let t="assets/img/common/fallback_avatar.png";
1(!this.contact.image||this.contact.image==="")&&(this.contact.image=t)}isNewSupportContact(){return!this.contact.id}ok(){this.activeModal.close(this.contact)}cancel(){this.activeModal.close()}static{this.\u0275fac=function(n){return new(n||i)}}static{this.\u0275cmp=E({type:i,selectors:[["app-contact-edit-modal"]],decls:44,vars:27,consts:[["newContact","ngForm"],["type","ngModel"],["name","ngModel"],["email","ngModel"],["phone","ngModel"],[1,"modal-header"],["id","modal-title",1,"modal-title"],["type","button","aria-label","Close",1,"btn-close",3,"click"],[3,"ngSubmit"],[1,"modal-body","modal-contacts"],[1,"row"],[1,"col-lg-6","col-xs-12"],[1,"form-group"],["for","type","translate",""],["name","type","type","text","id","type","required","true",1,"form-control",3,"ngModelChange","ngModel","ngClass"],["translate","",1,"invalid-feedback"],["for","name","translate",""],["name","name","type","text","id","name","required","true",1,"form-control",3,"ngModelChange","ngModel","ngClass"],["for","email","translate",""],["name","email","email","","type","email","id","email","required","true",1,"form-control",3,"ngModelChange","ngModel","ngClass"],["for","phone","translate",""],["name","phone","type","text","id","phone","required","true",1,"form-control",3,"ngModelChange","ngModel","ngClass"],[3,"contactChange","contact","preview"],[1,"modal-footer"],["type","button",1,"btn","btn-light",3,"click"],["translate",""],["type","submit",1,"btn","btn-primary",3,"disabled"]],template:function(n,e){if(n&1){let r=y();a(0,"div",5)(1,"h4",6),l(2),b(3,"translate"),o(),a(4,"button",7),h("click",function(){return e.cancel()}),o()(),a(5,"form",8,0),h("ngSubmit",function(){d(r);let v=Q(6);return u(v.valid&&e.ok())}),a(7,"div",9)(8,"div",10)(9,"div",11)(10,"div",12)(11,"label",13),l(12,"Department"),o(),a(13,"input",14,1),B("ngModelChange",function(v){return d(r),k(e.contact.type,v)||(e.contact.type=v),u(v)}),o(),g(15,_n,2,0,"span",15),o(),a(16,"div",12)(17,"label",16),l(18,"Name"),o(),a(19,"input",17,2),B("ngModelChange",function(v){return d(r),k(e.contact.name,v)||(e.contact.name=v),u(v)}),o(),g(21,fn,2,0,"span",15),o(),a(22,"div",12)(23,"label",18),l(24,"E-Mail"),o(),a(25,"input",19,3),B("ngModelChange",function(v){return d(r),k(e.contact.email,v)||(e.contact.email=v),u(v)}),o(),g(27,hn,2,0,"span",15),g(28,Cn,2,0,"span",15),o(),a(29,"div",12)(30,"label",20),l(31,"Phone"),o(),a(32,"input",21,4),B("ngModelChange",function(v){return d(r),k(e.contact.phone,v)||(e.contact.phone=v),u(v)}),o(),g(34,vn,2,0,"span",15),o()(),a(35,"div",11)(36,"app-contact-card",22),B("contactChange",function(v){return d(r),k(e.contact,v)||(e.contact=v),u(v)}),o()()()(),a(37,"div",23)(38,"button",24),h("click",function(){return e.cancel()}),a(39,"span",25),l(40,"Cancel"),o()(),a(41,"button",26)(42,"span",25),l(43,"Save"),o()()()()}if(n&2){let r=Q(6),x=Q(14),v=Q(20),N=Q(26),it=Q(33);s(2),O(e.isNewSupportContact()?"New support contact":S(3,17,"Edit support contact")),s(11),z("ngModel",e.contact.type),m("ngClass",X(19,Gt,x.touched&&x.invalid)),s(2),_(x.hasError("required")?15:-1),s(4),z("ngModel",e.contact.name),m("ngClass",X(21,Gt,v.touched&&v.invali
1d)),s(2),_(v.hasError("required")?21:-1),s(4),z("ngModel",e.contact.email),m("ngClass",X(23,Gt,N.touched&&N.invalid)),s(2),_(N.hasError("email")?27:-1),s(),_(N.hasError("required")?28:-1),s(4),z("ngModel",e.contact.phone),m("ngClass",X(25,Gt,it.touched&&it.invalid)),s(2),_(it.hasError("required")?34:-1),s(2),z("contact",e.contact),m("preview",!0),s(5),m("disabled",!r.valid)}},dependencies:[U,D,F,I,bt,lt,rt,Z,st,kt,de,ht,mt,ze,V],encapsulation:2})}}return i})();var Re=Kt($t(),1);var bn=()=>({prefix:"far",iconName:"plus"}),Sn=()=>({prefix:"far",iconName:"trash"}),xn=()=>({prefix:"far",iconName:"pencil-alt"}),Tn=(i,c)=>c.id;function yn(i,c){if(i&1){let t=y();a(0,"div",2)(1,"div",5)(2,"div",6)(3,"button",7),h("click",function(){d(t);let e=p();return u(e.onEditContact(void 0))}),C(4,"fa-icon",8),a(5,"span",9),l(6,"New support contact"),o()()()()()}if(i&2){let t=p();s(3),m("disabled",!t.currentUser.hasAdminRole()),s(),m("icon",M(2,bn))}}function En(i,c){i&1&&C(0,"ab-loading-spinner",4),i&2&&m("absolute",!1)}function wn(i,c){if(i&1){let t=y();a(0,"tr")(1,"td",18)(2,"button",19),b(3,"translate"),h("click",function(){let e=d(t).$implicit,r=p(2);return u(r.removeContact(e))}),C(4,"fa-icon",8),o(),a(5,"button",19),b(6,"translate"),h("click",function(){let e=d(t).$implicit,r=p(2);return u(r.onEditContact(e))}),C(7,"fa-icon",8),o()(),a(8,"td"),l(9),o(),a(10,"td"),l(11),o(),a(12,"td"),l(13),o(),a(14,"td"),l(15),o()()}if(i&2){let t=c.$implicit,n=p(2);s(2),m("title",q(S(3,12,"Delete support contact")))("disabled",!n.currentUser.hasAdminRole()),s(2),m("icon",M(16,Sn)),s(),m("title",q(S(6,14,"Edit contact")))("disabled",!n.currentUser.hasAdminRole()),s(2),m("icon",M(17,xn)),s(2),w(" ",t.name," "),s(2),w(" ",t.type," "),s(2),w(" ",t.email," "),s(2),w(" ",t.phone," ")}}function Mn(i,c){if(i&1){let t=y();a(0,"div",1)(1,"div",10)(2,"div",11)(3,"table",12)(4,"thead")(5,"tr")(6,"th",13),l(7,"Functions"),o(),a(8,"th",14),h("sort",function(e){d(t);let r=p();return u(r.onSort(e))}),a(9,"span",13),l(10,"Name"),o()(),a(11,"th",15),h("sort",function(e){d(t);let r=p();return u(r.onSort(e))}),a(12,"span",13),l(13,"Type"),o()(),a(14,"th",16),h("sort",function(e){d(t);let r=p();return u(r.onSort(e))}),a(15,"span",13),l(16,"E-Mail"),o()(),a(17,"th",17),h("sort",function(e){d(t);let r=p();return u(r.onSort(e))}),a(18,"span",13),l(19,"Phone"),o()()()(),a(20,"tbody"),P(21,wn,16,18,"tr",null,Tn),o()()()()()}if(i&2){let t=p();s(21),A(t.contacts)}}var We=(()=>{class i{constructor(){this.loading=!1,this.tableSortService=f(et),this.toastService=f(W),this.translateService=f(R),this.confirmModalService=f(yt),this.helperService=f(tt),this.adminTenantService=f(Y),this.modalService=f(Bt)}ngOnInit(){this.loadContacts()}loadContacts(){if(!this.tenant)return;this.loading=!0,this.adminTenantService.getContacts(this.tenant.id).subscribe({next:n=>{this.loading=!1,this.contacts=n,setTimeout(()=>{this.tableSortService.initialSortTableItems(n,"name","asc",this.headers)})},error:()=>{this.toastService.error(this.translateService.instant("The contacts could not be loaded!")),this.loading=!1}})}onSort({column:t,direction:n}){this.headers&&this.tableSortService.sortTableItems(this.contacts,t,n,this.headers)}removeContact(t){let n=this.translateService.instant("Delete support contact"),e=this.translateService.instant("Do you really want to permanently delete the support contact %s ?").replace("%s",this.helperService.getStringInStrongTags(t.name)),r=this.translateService.instant("Delete contact");this.confirmModalService.openConfirmModal(n,e,r).subscribe(v=>{if(v){if(!this.tenant)return;this.adminTenantService.deleteContact(this.tenant.id,t).subscribe({next:()=>{this.toastService.success(this.translateService.instant("The support contact: %s was deleted.").replace("%s",t.name))},error:()=>{this.toastService.error(this.translateService.instant("There was an error deleting support contact: ")+t.name+".")},complete:()=>{this.loadContacts()}})}})}onEditContact(t){let n=this.modalService.open(Be,{backdrop:"static",size:"lg"});t&&(n.componentInstance.contact=Re.cloneDeep(t)),n.closed.subscribe(e=>{if(!e||!this.tenant)return;this.adminTenantService.saveContact(this.tenant.id,e).subscribe({next:x=>{this.toastService.success(this.translateService.instant("Contact saved")+" "+
1x.name)},error:()=>{this.toastService.error(this.translateService.instant("There was an error saving contact"))},complete:()=>{this.loadContacts()}})})}static{this.\u0275fac=function(n){return new(n||i)}}static{this.\u0275cmp=E({type:i,selectors:[["app-organization-contacts"]],viewQuery:function(n,e){if(n&1&&H(L,5),n&2){let r;G(r=K())&&(e.headers=r)}},inputs:{currentUser:"currentUser",tenant:"tenant",contacts:"contacts"},decls:10,vars:13,consts:[[1,"container-fluid"],[1,"row"],[1,"col-12","col-sm-6"],[3,"heading","itemName","count","type"],[3,"absolute"],[1,"admin-page-buttons","btn-toolbar"],[1,"admin-page-btn-group"],[1,"btn","btn-primary",3,"click","disabled"],[3,"icon"],["translate","",1,"d-none","d-sm-inline"],[1,"col"],[1,"table-responsive"],[1,"table","table-striped"],["translate",""],["sortable","name",1,"sortable",3,"sort"],["sortable","type",1,"sortable",3,"sort"],["sortable","email",1,"sortable",3,"sort"],["sortable","phone",1,"sortable",3,"sort"],["data-cell-buttons","2"],["type","button",1,"btn","btn-sm","btn-light",3,"click","disabled","title"]],template:function(n,e){n&1&&(a(0,"div",0)(1,"div",1)(2,"div",2),C(3,"app-admin-config-page-header",3),b(4,"translate"),b(5,"translate"),b(6,"translate"),o(),g(7,yn,7,3,"div",2),o(),g(8,En,1,1,"ab-loading-spinner",4),g(9,Mn,23,0,"div",1),o()),n&2&&(s(3),m("heading",S(4,7,"Organization"))("itemName",e.tenant?e.tenant.name:"")("count",e.contacts?e.contacts.length:0)("type",e.contacts&&e.contacts.length===1?S(5,9,"Support contact"):S(6,11,"Support contacts")),s(4),_(e.currentUser?7:-1),s(),_(!e.tenant||!e.currentUser||!e.contacts||e.loading?8:-1),s(),_(e.contacts&&e.currentUser&&e.tenant&&!e.loading?9:-1))},dependencies:[F,I,nt,j,$,L,V],encapsulation:2})}}return i})();var Ge=(()=>{class i extends Dt{constructor(){super()}fromModel(t){if(!t)return null;let n=new Date(t);return{year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}}toModel(t){return t?new Date(t.year,t.month-1,t.day):null}static{this.\u0275fac=function(n){return new(n||i)}}static{this.\u0275prov=_t({token:i,factory:i.\u0275fac,providedIn:"root"})}}return i})();var Ke=(()=>{class i extends Ut{constructor(){super(),this.separator="/"}format(t){return t?t.year+this.separator+t.month+this.separator+t.day:""}parse(t){if(!t)return null;let n=t.split(this.separator);return{day:parseInt(n[2],10),month:parseInt(n[1],10),year:parseInt(n[0],10)}}static{this.\u0275fac=function(n){return new(n||i)}}static{this.\u0275prov=_t({token:i,factory:i.\u0275fac,providedIn:"root"})}}return i})();var In=()=>({prefix:"far",iconName:"trash"}),Xt=i=>({"is-invalid":i});function Vn(i,c){i&1&&(a(0,"span",8),l(1," Value required "),o())}function Fn(i,c){i&1&&(a(0,"span",8),l(1," The value does not match the portal setting type "),o())}function Nn(i,c){i&1&&(a(0,"span",8),l(1," Start date required "),o())}function On(i,c){i&1&&(a(0,"span",8),l(1," End date is before start date "),o())}function Pn(i,c){i&1&&(a(0,"span",8),l(1," Intervals are overlapping "),o())}function An(i,c){i&1&&(a(0,"span",8),l(1," End date required "),o())}function zn(i,c){i&1&&(a(0,"span",8),l(1," End date is before start date "),o())}function kn(i,c){i&1&&(a(0,"span",8),l(1," Intervals are overlapping "),o())}function Dn(i,c){if(i&1){let t=y();a(0,"div",1)(1,"div",2)(2,"button",3),b(3,"translate"),h("click",function(){d(t);let e=p();return u(e.onRemoveInterval(e.constantValue))}),C(4,"fa-icon",4),o()(),a(5,"div",5)(6,"div",6)(7,"input",7),h("change",function(){d(t);let e=p();return u(e.onValueChange(e.valueItemForm))}),o(),g(8,Vn,2,0,"span",8),g(9,Fn,2,0,"span",8),o()(),a(10,"div",9)(11,"div",10),C(12,"input",11),g(13,Nn,2,0,"span",8),g(14,On,2,0,"span",8),g(15,Pn,2,0,"span",8),o()(),a(16,"div",9)(17,"div",10),C(18,"input",12),g(19,An,2,0,"span",8),g(20,zn,2,0,"span",8),g(21,kn,2,0,"span",8),o()()()}if(i&2){let t=p();s(2),m("title",S(3,17,"Delete interval")),s(2),m("icon",M(19,In)),s(3),m("ngClass",X(20,Xt,!t.valueItemForm.controls.value.untouched&&t.valueItemForm.controls.value.invalid)),s(),_(t.valueItemForm.controls.value.hasError("required")?8:-1),s(),_(t.valueItemForm.controls.value.hasError("invalidValue")?9:-1),s(3),m("placeholder",q(t.dateFormat))("ngClass",X(22,Xt,!t.valueItemForm.controls.startTimestamp.untouched&&t.valueItemForm.controls.startTimestamp.invalid)),s(),_(t.valueItemForm.controls.startTimestamp.hasError("required")?13:-1),s(),_(t.valueItemForm.controls.startTimestamp.hasError("invalidDate")?14:-1),s(),_(t.valueItemForm.controls.startTimestamp.hasError("overlapping")?15:-1),s(3),m("placeholder",q(t.dateFormat))("ngClass",X(24,Xt,!t.valueItemForm.controls.endTimestamp.untouched&&t.valueItemForm.controls.endTimestamp.invalid)),s(),_(t.valueItemForm.controls.endTimestamp.hasError("required")?19:-1),s(),_(t.valueItemForm.controls.endTimestamp.hasError("invalidDate")?20:-1),s(),_(t.valueItemForm.controls.endTimestamp.hasError("overlapping")?21:-1)}}var Zt=(()=>{class i{constructor(){this.helperService=f(tt),this.valueItemForm=new ut({}),this.constantValueChange=new Et,this.portalSettingChange=new Et,this.allIntervals=[],this.allIntervalsChange=new Et,this.removeInterval=new Et,this.dateFormat="yyyy/MM/dd",this.parentFormGroup=new ut({}),this.index=-1}ngOnInit(){let t=this.parentFormGroup.controls.editValuesFormArray;this.valueItemForm=t.controls[this.index],this.valueItemForm.controls.startTimestamp.valueChanges.subscribe(()=>{this.onStartDateChange()}),this.valueItemForm.controls.endTimestamp.valueChanges.subscribe(()=>{this.onEndDateChange()})}onRemoveInterval(t){this.removeInterval&&(this.removeInterval.emit(t),this.removeValueItemForm(this.parentFormGroup,this.index))}onValueChange(t){this.constantValue&&this.portalSetting&&(this.constantValue.value=t.controls.value.value,this.portalSetting=t.controls.portalSetting?t.controls.portalSetting.value:this.portalSetting,this.helperService.validatedValueByPortalSettingTypePassedValue(this.constantValue.value,this.portalSetting)?t.controls.value.setErrors(null):t.controls.value.setErrors({invalidValue:!0}))}onStartDateChange(){this.resetDateErrors(),this.checkDatesValidity(),this.constantValue&&(this.constantValue.startTimestamp=new Date(this.valueItemForm.controls.startTimestamp.value),this.areIntervalsInvalid(this.constantValue))}onEndDateChange(){this.resetDateErrors(),this.checkDatesValidity(),this.constantValue&&(this.constantValue.endTimestamp=new Date(this.valueItemForm.controls.endTimestamp.value),this.areIntervalsInvalid(this.constantValue))}removeValueItemForm(t,n){t.controls.editValuesFormArray.removeAt(n)}checkDatesValidity(){this.isEndBeforeStart()&&(this.valueItemForm.controls.startTimestamp.setErrors({invalidDate:!0}),this.valueItemForm.controls.endTimestamp.setErrors({invalidDate:!0}))}areIntervalsInvalid(t){for(let n of this.allIntervals)this.helperService.areTenantConstantValuesOverlapping(t,n)&&(this.valueItemForm.controls.endTimestamp.setErrors({overlapping:!0}),this.valueItemForm.controls.startTimestamp.setErrors({overlapping:!0}))}isEndBeforeStart(){let t=this.valueItemForm.controls.startTimestamp.value,
1n=this.valueItemForm.controls.endTimestamp.value;if(!t||!n)return!1;let e,r;return e=new Date(t).getTime(),r=new Date(n).getTime(),e&&r?r<e:!1}resetDateErrors(){this.valueItemForm.controls.startTimestamp.setErrors(null),this.valueItemForm.controls.endTimestamp.setErrors(null)}static{this.\u0275fac=function(n){return new(n||i)}}static{this.\u0275cmp=E({type:i,selectors:[["app-constant-value-item"]],inputs:{constantValue:"constantValue",portalSetting:"portalSetting",allIntervals:"allIntervals",dateFormat:"dateFormat",parentFormGroup:"parentFormGroup",index:"index"},outputs:{constantValueChange:"constantValueChange",portalSettingChange:"portalSettingChange",allIntervalsChange:"allIntervalsChange",removeInterval:"removeInterval"},features:[Ft([{provide:Dt,useClass:Ge},{provide:Ut,useClass:Ke}],[{provide:Pt,useExisting:mt}])],decls:2,vars:2,consts:[[3,"formGroup"],[1,"row"],[1,"col-xs-1","col-sm-1"],["type","button",1,"btn","btn-sm","btn-default",3,"click","title"],[3,"icon"],[1,"col-xs-12","col-sm-3"],[1,"form-group"],["name","value","id","value","type","text","formControlName","value",1,"form-control",3,"change","ngClass"],["translate","",1,"invalid-feedback"],[1,"col-xs-12","col-sm-4"],[1,"input-group"],["name","startTimestamp","formControlName","startTimestamp","type","date",1,"form-control",3,"placeholder","ngClass"],["type","date","name","endTimestamp","formControlName","endTimestamp",1,"form-control",3,"placeholder","ngClass"]],template:function(n,e){n&1&&(a(0,"form",0),g(1,Dn,22,26,"div",1),o()),n&2&&(m("formGroup",e.valueItemForm),s(),_(e.constantValue?1:-1))},dependencies:[U,D,F,I,St,lt,rt,Z,st,vt,Ct,j,V],encapsulation:2})}}return i})();var qe=Kt($t(),1);var Ln=["newConstant"],Bn=i=>({"is-invalid":i}),Rn=()=>({prefix:"far",iconName:"plus"});function Wn(i,c){i&1&&(a(0,"span",14),l(1," Portal setting required "),o())}function Gn(i,c){i&1&&(a(0,"div",6)(1,"div",24),C(2,"span"),o(),a(3,"div",25)(4,"span",26),l(5,"Value"),o()(),a(6,"div",27)(7,"span",26),l(8,"Start"),o()(),a(9,"div",27)(10,"span",26),l(11,"End"),o()()())}function Kn(i,c){if(i&1){let t=y();a(0,"div")(1,"app-constant-value-item",28),B("constantValueChange",function(e){let r=d(t).$index,x=p(4);return k(x.constant.tenantConstant.constantValues[r],e)||(x.constant.tenantConstant.constantValues[r]=e),u(e)})("portalSettingChange",function(e){d(t);let r=p(4);return k(r.constant.portalSetting,e)||(r.constant.portalSetting=e),u(e)})("allIntervalsChange",function(e){d(t);let r=p(4);return k(r.constant.tenantConstant.constantValues,e)||(r.constant.tenantConstant.constantValues=e),u(e)}),h("removeInterval",function(){let e=d(t).$index,r=p(4);return u(r.onRemoveInterval(r.constant.tenantConstant.constantValues[e]))}),o()()}if(i&2){let t=c.$index,n=p(4);s(),z("constantValue",n.constant.tenantConstant.constantValues[t]),m("index",t),z("portalSetting",n.constant.portalSetting),m("parentFormGroup",n.tenantConstantForm),z("allIntervals",n.constant.tenantConstant.constantValues),m("dateFormat",n.dateFormat)}}function qn(i,c){if(i&1){let t=y();a(0,"div",20),g(1,Gn,12,0,"div",6),P(2,Kn,2,6,"div",null,ot),a(4,"button",21),h("click",function(){d(t);let e=p(3);return u(e.onAddInterval())}),C(5,"fa-icon",22),a(6,"span",23),l(7,"New constant interval"),o()()()}if(i&2){let t=p(3);s(),_(t.constant.tenantConstant.constantValues.length>0?1:-1),s(),A(t.constant.tenantConstant.constantValues),s(3),m("icon",M(2,Rn))}}function Hn(i,c){if(i&1){let t=y();a(0,"div",6)(1,"div",10)(2,"div",11)(3,"label",12),l(4,"Portal setting"),o(),a(5,"ng-select",13),h("change",function(e){d(t);let r=p(2);return u(r.changePortalSetting(e))}),o(),g(6,Wn,2,0,"span",14),o()(),a(7,"div",15)(8,"div",11)(9,"label",16),l(10,"Unit"),o(),C(11,"input",17),o()(),a(12,"div",15)(13,"div",11)(14,"label",18),l(15,"Decimal places"),o(),C(16,"input",19),o()(),a(17,"div",6),g(18,qn,8,3,"div",20),o()()}if(i&2){let t,n,e=p(2);s(5),m("clearable",!1)("readonly",!e.isNewConstant())("items",e.portalSettings)("ngClass",X(6,Bn,((t=e.tenantConstantForm.get("portalSetting"))==null?null:t.touched)&&((t=e.tenantConstantForm.get("portalSetting"))==null?null:t.invali
1d))),s(),_((n=e.tenantConstantForm.get("portalSetting"))!=null&&n.hasError("required")?6:-1),s(12),_(e.constant&&e.constant.tenantConstant.constantValues?18:-1)}}function Qn(i,c){if(i&1){let t=y();a(0,"form",4),h("ngSubmit",function(){d(t);let e=p();return u(e.ok())}),a(1,"div",5),g(2,Hn,19,8,"div",6),o(),a(3,"div",7)(4,"button",8),h("click",function(){d(t);let e=p();return u(e.cancel())}),l(5,"Cancel"),o(),a(6,"button",9),l(7,"Save"),o()()()}if(i&2){let t=p();m("formGroup",t.tenantConstantForm),s(2),_(t.constant.tenantConstant&&t.constant.portalSetting?2:-1),s(4),m("disabled",t.submitDisabled())}}var He=(()=>{class i{constructor(t,n,e,r){this.activeModal=t,this.route=n,this.fb=e,this.helperService=r,this.tenantConstantForm=new ut({}),this.constant=new Jt(void 0),this.portalSettings=[],this.constants=[],this.tenantId=-1,this.dateFormat="yyyy/MM/dd"}ngOnInit(){this.tenantConstantForm=this.generateForm(this.constant);let t=this.route.snapshot.paramMap.get("tenantId");t&&(this.tenantId=parseInt(t),this.constant.tenantConstant||(this.constant.tenantConstant=new Yt(void 0),this.constant.tenantConstant.tenantId=this.tenantId))}changePortalSetting(t){this.tenantConstantForm.controls.portalSetting.setValue(t),this.constant.portalSetting=t}cancel(){this.activeModal.close()}isNewConstant(){return!this.constant.tenantConstant||this.constant.tenantConstant.id===-1}ok(){let t=this.parseFormValues(this.tenantConstantForm);this.activeModal.close(t)}onRemoveInterval(t){if(!this.constant||!this.constant.tenantConstant)return;let n=this.constant.tenantConstant.constantValues.indexOf(t);n>-1&&this.constant.tenantConstant.constantValues.splice(n,1)}constantIntervalsInvalid(){let t=!1,n=!1,e=!1;if(!this.constant||!this.constant.tenantConstant||!this.constant.portalSetting)return!1;for(let r of this.constant.tenantConstant.constantValues)t=t||this.onIsConstantWithSameNameAndOverlappingPeriod(r,this.constant.tenantConstant.constantValues),n=n||this.helperService.onIsDateInvalid(r),e=e||!this.helperService.validatedValueByPortalSettingTypePassedValue(r.value,this.constant.portalSetting);return t||n||e}onIsConstantWithSameNameAndOverlappingPeriod(t,n){let e=!1;for(let r of n)qe.isEqual(t,r)||(e=e||this.helperService.areTenantConstantValuesOverlapping(t,r));return e}onAddInterval(){this.constant.tenantConstant||(this.constant.tenantConstant=new Yt(void 0)),this.constant.tenantConstant.constantValues||(this.constant.tenantConstant.constantValues=[]);let t=new Pe({value:"",startTimestamp:null,endTimestamp:null});this.constant.tenantConstant.constantValues.push(t),this.addValueItemForm(this.tenantConstantForm,t)}addValueItemForm(t,n){let e=t.controls.editValuesFormArray,r=e.length;e.insert(r,this.generateConstantValueItemFormGroup(n))}submitDisabled(){return this.constantIntervalsInvalid()}generateForm(t){let n=this.fb.group({portalSetting:[t.portalSetting,Mt.required],unit:[t.tenantConstant?.unit],decimalPlaces:[t.tenantConstant?.decimalPlaces],editValuesFormArray:this.fb.array([])}),e=n.controls.editValuesFormArray,r=e.length;t.tenantConstant.constantValues||(t.tenantConstant.constantValues=new Array);for(let x of t.tenantConstant.constantValues)e.insert(r,this.generateConstantValueItemFormGroup(x));return n}generateConstantValueItemFormGroup(t){return this.fb.group({value:[t.value,[Mt.required]],startTimestamp:[this.helperService.getDateString(t.startTimestamp),[Mt.required]],endTimestamp:[this.helperService.getDateString(t.endTimestamp),[Mt.required]]})}parseFormValues(t){let n=new Jt(void 0);if(!n.tenantConstant)return n;n.tenantConstant.tenantId=this.tenantId,n.tenantConstant.id=this.constant.tenantConstant?.id,n.portalSetting=t.controls.portalSetting.value,n.tenantConstant.unit=t.controls.unit.value,n.tenantConstant.decimalPlaces=t.controls.decimalPlaces.value;let r=t.controls.editValuesFormArray.controls;for(let x of r){let v={value:x.controls.value.value,startTimestamp:x.controls.startTimestamp.value,endTimestamp:x.controls.endTimestamp.value};n.tenantConstant.constantValues.push(v)}return n}static{this.\u0275fac=function(n){return new(n||i)(wt(Lt),wt(Tt),wt(ge),wt(tt))}}static{this.\u0275cmp=E({type:i,selectors:[["app-constant-edit-modal"]],viewQuery:function(n,e){if(n&1&&H(Zt,7)(Ln,5),n&2){let r;G(r=K())&&(e.constantValueItemComponent=r.first),G(r=K())&&(e.newConstantForm=r.first)}},features:[Ft([],[{provide:Pt,useExisting:mt}])],decls:6,vars:4,consts:[[1,"modal-header"],["id","modal-title",1,"modal-title"],["type","button","aria-label","Close",1,"btn-close",3,"click"],[3,"formGroup"],[3,"ngSubmit","formGroup"],[1,"modal-body"],[1,"row"],[1,"modal-footer"],["type","button","translate","",1,"btn","btn-light",3,"click"],["type","submit","translate","",1,"btn","btn-primary",3,"disabled"],[1,"col-lg-12","col-xs-12"],[1,"form-group"],["for","portalSetting","translate",""],["id","portalSetting","formControlName","portalSetting","appendTo","ngb-modal-window","bindLabel","name",1,"form-control",3,"change","clearable","readonly","items","ngClass"],["translate","",1,"invalid-feedback"],[1,"col-lg-6","col-xs-12"],["for","unit","translate",""],["formControlName","unit","id","unit","type","text",1,"form-control"],["for","decimalPlaces","translate",""],["formControlName","decimalPlaces","id","decimalPlaces","type","number","min","0","max","9",1,"form-control"],[1,"col-xs-12"],["type","button",1,"btn","btn-primary",3,"click"],[3,"icon"],["translate","",1,"d-none","d-xl-inline"],[1,"col-12","col-sm-1","hidden-xs"],[1,"col-12","col-sm-3","hidden-xs"],["translate",""],[1,"col-12","col-sm-4","hidden-xs"],[3,"constantValueChange","portalSettingChange","allIntervalsChange","removeInterval","constantValue","index","portalSetting","parentFormGroup","allIntervals","dateFormat"]],template:function(n,e){n&1&&(a(0,"div",0)(1,"h4",1),l(2),b(3,"translate"),o(),a(4,"button",2),h("click",function(){return e.cancel()}),o()(),g(5,Qn,8,3,"form",3)),n&2&&(s(2),O(e.isNewConstant()?"New constant":S(3,2,"Edit constant")),s(3),_(e.tenantConstantForm&&e.portalSettings?5:-1))},dependencies:[U,D,F,I,St,lt,rt,At,Z,st,zt,me,vt,Ct,Wt,Zt,j,V],encapsulation:2})}}return i})();var Qe=Kt($t(),1);var jn=()=>({prefix:"far",iconName:"plus"}),$n=()=>({prefix:"far",iconName:"trash"}),Yn=()=>({prefix:"far",iconName:"pencil-alt"}),te=(i,c)=>({"text-primary fw-bold":i,"fst-italic":c});function Jn(i,c){if(i&1){let t=y();a(0,"div",2)(1,"div",5)(2,"div",6)(3,"button",7),h("click",function(){d(t);let e=p();return u(e.onEditConstant(void 0))}),C(4,"fa-icon",8),a(5,"span",9),l(6,"New organization constant"),o()()()()()}if(i&2){let t=p();s(3),m("disabled",!t.currentUser.hasAdminRole()),s(),m("icon",M(2,jn))}}function Xn(i,c){i&1&&C(0,"ab-loading-spinner",4),i&2&&m("absolute",!1)}function Zn(i,c){if(i&1&&(a(0,"td"),l(1),o()),i&2){let t=p().$implicit;s(),w(" ",t.portalSetting.name," ")}}function ti(i,c){if(i&1&&(a(0,"td"),l(1),b(2,"translate"),o()),i&2){let t=p().$implicit;s(),w(" ",S(2,1,t.portalSetting.value)," ")}}function ei(i,c){if(i&1&&(a(0,"div",1)(1,"div",21)(2,"span",22),l(3),o()(),a(4,"div",21)(5,"span",22),l(6),b(7,"date"),o()(),a(8,"div",21)(9,"span",22),l(10),b(11,"date"),o()()()),i&2){let t=c.$implicit,n=p(4);s(2),m("ngClass",Nt(16,te,n.isActiveInterval(t),n.intervalIsInPast(t))),s(),w(" ",t.value," "),s(2),m("ngClass",Nt(19,te,n.isActiveInterval(t),n.intervalIsInPast(t))),s(),w(" ",jt(7,6,t.startTimestamp,"mediumDate",void 0,n.translationService.currentLang())," "),s(3),m("ngClass",Nt(22,te,n.isActiveInterval(t),n.intervalIsInPast(t))),s(),w(" ",jt(11,11,t.endTimestamp,"mediumDate",void 0,n.translationService.currentLang())," ")}}function ni(i,c){if(i&1&&(a(0,"td",20),P(1,ei,12,25,"div",1,ot),o()),i&2){let t=p().$implicit;s(),A(t.tenantConstant.constantValues)}}function ii(i,c){if(i&1&&(a(0,"td"),l(1),o()),i&2){let t=p().$implicit;s(),O(t.tenantConstant.unit)}}function ai(i,c){if(i&1&&(a(0,"td"),l(1),o()),i&2){let t=p().$implicit;s(),O(t.tenantConstant.decimalPlaces)}}function oi(i,c){if(i&1){let t=y();a(0,"tr")(1,"td",18)(2,"button",19),b(3,"translate"),h("click",function(){let e=d(t).$implicit,r=p(2);return u(r.removeConstant(e))}),C(4,"fa-icon",8),o(),a(5,"button",19),b(6,"translate"),h("click",function(){let e=d(t).$implicit,r=p(2);return u(r.onEditConstant(e))}
1),C(7,"fa-icon",8),o()(),g(8,Zn,2,1,"td"),g(9,ti,3,3,"td"),g(10,ni,3,0,"td",20),g(11,ii,2,1,"td"),g(12,ai,2,1,"td"),o()}if(i&2){let t=c.$implicit,n=p(2);s(2),m("title",q(S(3,13,"Delete constant")))("disabled",n.isUserAdmin()),s(2),m("icon",M(17,$n)),s(),m("title",q(S(6,15,"Edit constant")))("disabled",n.isUserAdmin()),s(2),m("icon",M(18,Yn)),s(),_(t.portalSetting?8:-1),s(),_(t.portalSetting?9:-1),s(),_(t.tenantConstant?10:-1),s(),_(t.tenantConstant?11:-1),s(),_(t.tenantConstant?12:-1)}}function ri(i,c){if(i&1){let t=y();a(0,"div",1)(1,"div",10)(2,"div",11)(3,"table",12)(4,"thead")(5,"tr")(6,"th",13),l(7,"Functions"),o(),a(8,"th",14),h("sort",function(e){d(t);let r=p();return u(r.onSortValueItems(e))}),a(9,"span",13),l(10,"Name"),o()(),a(11,"th",15),h("sort",function(e){d(t);let r=p();return u(r.onSortValueItems(e))}),a(12,"span",13),l(13,"Type"),o()(),a(14,"th")(15,"span",13),l(16,"Value"),o()(),a(17,"th")(18,"span",13),l(19,"Start"),o()(),a(20,"th")(21,"span",13),l(22,"End"),o()(),a(23,"th",16),h("sort",function(e){d(t);let r=p();return u(r.onSortValueItems(e))}),a(24,"span",13),l(25,"Unit of Measure"),o()(),a(26,"th",17),h("sort",function(e){d(t);let r=p();return u(r.onSortValueItems(e))}),a(27,"span",13),l(28,"Decimal places"),o()()()(),a(29,"tbody"),P(30,oi,13,19,"tr",null,ot),o()()()()()}if(i&2){let t=p();s(30),A(t.constants)}}var je=(()=>{class i{constructor(){this.dateFormat="yyyy/MM/dd",this.tableSortService=f(et),this.toastService=f(W),this.confirmModalService=f(yt),this.helperService=f(tt),this.adminTenantService=f(Y),this.modalService=f(Bt),this.translateService=f(R),this.translationService=f(Rt)}ngOnInit(){this.loadPortalSettings(),this.getTenantConstants()}getTenantConstants(){if(!this.tenant)return;this.adminTenantService.getConstants(this.tenant.id).subscribe({next:n=>{this.constants=n,setTimeout(()=>{this.tableSortService.initialSortTableItems(n,"name","asc",this.headers)})},error:()=>{this.toastService.error(this.translateService.instant("There is an error in getting constants"))}})}loadPortalSettings(){if(!this.tenant)return;this.adminTenantService.listPortalSettings(this.tenant.id).subscribe({next:n=>{this.portalSettings=n},error:()=>{this.toastService.error(this.translateService.instant("There is an error in loading portal settings"))}})}onEditConstant(t){this.constants||(this.constants=[]),this.portalSettings||(this.portalSettings=[]);let n=this.filterOutUsedPortalSettings(this.constants,this.portalSettings),e=this.modalService.open(He,{backdrop:"static",size:"lg"});t&&(e.componentInstance.constant=Qe.cloneDeep(t)),e.componentInstance.portalSettings=n,e.componentInstance.constants=this.constants,e.closed.subscribe(r=>{if(!r||!this.tenant||!r.tenantConstant)return;r.tenantConstant.tenantId=this.tenant.id,this.adminTenantService.saveConstant(this.tenant.id,r).subscribe({next:()=>{this.toastService.success(this.translateService.instant("Constant saved"))},error:()=>{this.toastService.error(this.translateService.instant("There was an error saving constant"))},complete:()=>{this.getTenantConstants()}})})}onSortValueItems({column:t,direction:n}){this.headers&&this.tableSortService.sortTableItems(this.constants,t,n,this.headers)}isUserAdmin(){return this.currentUser?!this.currentUser.hasAdminRole():!1}removeConstant(t){let n=this.translateService.instant("Delete organization constant"),e=this.translateService.instant("Do you really want to permanently delete the organization constant %s ?").replace("%s",this.helperService.getStringInStrongTags(t.portalSetting?t.portalSetting.name:"")),r=this.translateService.instant("Delete constant");this.confirmModalService.openConfirmModal(n,e,r).subscribe({next:v=>{if(this.tenant&&v&&t.tenantConstant){let N=this.adminTenantService.deleteConstant(this.tenant.id,t.tenantConstant),it=t.portalSetting?t.portalSetting.name:"";N.subscribe({next:()=>{this.toastService.success(this.translateService.instant("The constant %s was deleted.").replace("%s",it))},error:()=>{this.toastService.error(this.translateService.instant("There was an error deleting constant: ")+it+".")},complete:()=>{this.loadConstants()}})}}})}loadConstants(){if(!this.tenant)return;this.adminTenantService.getConstants(this.tenant.id).subscribe({next:n=>{this.constants=n},error:()=>{this.toastService.error(this.translateService.instant("There is an error in getting constants"))}})}filterOutUsedPortalSettings(t,n){let e=new Array;for(let r of n){let x=r.id,v=!1;for(let N of t)if(N.portalSetting&&N.portalSetting.id===x){v=!0;break}v||e.push(r)}return e}intervalIsInPast(t){return this.helperService.constantIntervalIsInPast(t)}isActiveInterval(t){return this.helperService.constantIntervalIsActive(t)}static{this.\u0275fac=function(n){return new(n||i)}}static{this.\u0275cmp=E({type:i,selectors:[["app-organization-constants"]],viewQuery:function(n,e){if(n&1&&H(L,5),n&2){let r;G(r=K())&&(e.headers=r)}},inputs:{currentUser:"currentUser",tenant:"tenant"},decls:10,vars:13,consts:[[1,"container-fluid"],[1,"row"],[1,"col-12","col-sm-6"],[3,"heading","itemName","count","type"],[3,"absolute"],[1,"admin-page-buttons","btn-toolbar"],[1,"admin-page-btn-group"],[1,"btn","btn-primary",3,"click","disabled"],[3,"icon"],["translate","",1,"d-none","d-sm-inline"],[1,"col"],[1,"table-responsive"],[1,"table","table-striped"],["translate",""],["sortable","name",1,"sortable",3,"sort"],["sortable","value",1,"sortable",3,"sort"],["sortable","unit",1,"sortable",3,"sort"],["sortable","decimalPlaces",1,"sortable",3,"sort"],["data-cell-buttons","2"],["type","button",1,"btn","btn-sm","btn-light",3,"click","disabled","title"],["colspan","3"],[1,"col-4"],[3,"ngClass"]],template:function(n,e){n&1&&(a(0,"div",0)(1,"div",1)(2,"div",2),C(3,"app-admin-config-page-header",3),b(4,"translate"),b(5,"translate"),b(6,"translate"),o(),g(7,Jn,7,3,"div",2),o(),g(8,Xn,1,1,"ab-loading-spinner",4),g(9,ri,32,0,"div",1),o()),n&2&&(s(3),m("heading",S(4,7,"Organization"))("itemName",e.tenant?e.tenant.name:"")("count",e.constants?e.constants.length:0)("type",e.constants&&e.constants.length===1?S(5,9,"Organization constant"):S(6,11,"Organization constants")),s(4),_(e.currentUser?7:-1),s(),_(!e.constants||!e.currentUser||!e.tenant?8:-1),s(),_(e.constants&&e.currentUser&&e.tenant?9:-1))},dependencies:[U,D,F,I,nt,j,$,L,se,V],encapsulation:2})}}return i})();var si=()=>({prefix:"far",iconName:"retweet-alt"}),li=()=>({prefix:"far",iconName:"trash"}),ci=()=>
1({prefix:"far",iconName:"check"}),pi=()=>({prefix:"far",iconName:"copy"});function mi(i,c){if(i&1){let t=y();a(0,"div",4)(1,"button",6),b(2,"translate"),h("click",function(){d(t);let e=p();return u(e.reloadPublicPages(e.tenant))}),C(3,"fa-icon",7),o()()}i&2&&(s(),m("title",S(2,2,"Reload public pages")),s(2),m("icon",M(4,si)))}function di(i,c){i&1&&C(0,"ab-loading-spinner",5),i&2&&m("absolute",!1)}function ui(i,c){if(i&1){let t=y();a(0,"button",28),h("click",function(){let e=d(t).$implicit,r=p(2).$implicit,x=p(2);return u(x.changeLanguage(r.publicPageClient,x.tenant,e.value))}),a(1,"span"),l(2),o(),C(3,"span",29),o()}if(i&2){let t=c.$implicit,n=p(2).$implicit,e=p(2);m("ngClass",n.publicPageClient.language===t.value?"active":""),s(2),O(t.key),s(),Ht("p-2 fib fi-"+e.getLanguageFlagKey(t.value))}}function gi(i,c){if(i&1&&(a(0,"button",23),b(1,"translate"),C(2,"button",24),a(3,"div",25)(4,"h6",26),l(5,"Language"),o(),P(6,ui,4,4,"button",27,ot),b(8,"keyvalue"),o()()),i&2){let t=p().$implicit,n=p(2);m("ngbTooltip",S(1,3,"Language")),s(2),Ht("fib fi-"+n.getLanguageFlagKey(t.publicPageClient.language)),s(4),A(S(8,5,n.languages))}}function _i(i,c){if(i&1){let t=y();a(0,"tr")(1,"td",19)(2,"div",20)(3,"button",21),b(4,"translate"),h("click",function(){let e=d(t).$implicit,r=p(2);return u(r.removePublicPage(e.publicPageClient,r.currentUser,r.tenant))}),C(5,"fa-icon",7),o(),a(6,"button",21),b(7,"translate"),h("click",function(){let e=d(t).$implicit,r=p(2);return u(r.onApprove(e.publicPageClient,r.currentUser,r.tenant))}),C(8,"fa-icon",7),o(),a(9,"button",22),b(10,"translate"),h("click",function(){let e=d(t).$implicit,r=p(2);return u(r.onCopyUrl(e.url))}),C(11,"fa-icon",7),o(),g(12,gi,9,7,"button",23),o()(),a(13,"td"),l(14),o(),a(15,"td"),l(16),o(),a(17,"td"),l(18),o(),a(19,"td"),l(20),o(),a(21,"td"),l(22),o(),a(23,"td"),l(24),o()()}if(i&2){let t=c.$implicit,n=p(2);ae("new-public-client-row",t.publicPageClient&&!n.isApproved(t.publicPageClient)),s(3),m("disabled",n.deleteButtonDisabled(t.publicPageClient,n.currentUser))("ngbTooltip",S(4,17,"Delete public page client")),s(2),m("icon",M(23,li)),s(),m("disabled",n.approveDisabled(t.publicPageClient,n.currentUser))("ngbTooltip",S(7,19,"Approve public page client")),s(2),m("icon",M(24,ci)),s(),m("ngbTooltip",S(10,21,"Copy url to clipboard")),s(2),m("icon",M(25,pi)),s(),_(t.publicPageClient?12:-1),s(2),O(t.machineName),s(2),O(t.label),s(2),O(t.publicPageClient==null?null:t.publicPageClient.systemName),s(2),O(n.showPrivatePassword(t.publicPageClient)),s(2),O(n.showPrivateFingerprint(t.publicPageClient)),s(2),O(n.isApproved(t.publicPageClient))}}function fi(i,c){if(i&1){let t=y();a(0,"div",1)(1,"div",8)(2,"div",9)(3,"table",10)(4,"thead")(5,"tr")(6,"th",11),l(7,"Functions"),o(),a(8,"th",12),h("sort",function(e){d(t);let r=p();return u(r.onSort(e))}),a(9,"span",11),l(10,"Asset"),o()(),a(11,"th",13),h("sort",function(e){d(t);let r=p();return u(r.onSort(e))}),a(12,"span",11),l(13,"Page"),o()(),a(14,"th",14),h("sort",function(e){d(t);let r=p();return u(r.onSort(e))}),a(15,"span",11),l(16,"System name"),o()(),a(17,"th",15),h("sort",function(e){d(t);let r=p();return u(r.onSort(e))}),a(18,"span",11),l(19,"Password"),o()(),a(20,"th",16),h("sort",function(e){d(t);let r=p();return u(r.onSort(e))}),a(21,"span",11),l(22,"Fingerprint"),o()(),a(23,"th",17),h("sort",function(e){d(t);let r=p();return u(r.onSort(e))}),a(24,"span",11),l(25,"Approved"),o()()()(),a(26,"tbody"),P(27,_i,25,26,"tr",18,ot),o()()()()()}if(i&2){let t=p();s(27),A(t.publicPages)}}var $e=(()=>{class i{constructor(){this.publicPages=[],this.languages=T,this.loading=!1,this.destroyRef=f(ft),this.tableSortService=f(et),this.toastService=f(W),this.adminTenantService=f(Y),this.translateService=f(R),this.translationService=f(Rt),this.helperService=f(tt),this.publicPageService=f(De),this.confirmModalService=f(yt)}ngOnInit(){this.tenant&&this.loadPublicPages(this.tenant)}onSort({column:t,direction:n}){this.headers&&this.tableSortService.sortTableItems(this.publicPages,t,n,this.headers)}deleteButtonDisabled(t,n){return t?!n.isSuperadmin():!0}removePublicPage(t,n,e){if(!n.isSuperadmin()||!t)return;let r=this.translateService.instant("Delete public page client"),x=this.translateService.instant("Do you really want to permanently delete the public page client %s ?").replace("%s",this.helperService.getStringInStrongTags(t.systemName)),v=this.translateService.instant("Delete client");this.confirmModalService.openConfirmModal(r,x,v).subscribe(it=>{it&&(this.loading=!0,this.publicPageService.delete(e,t).pipe(at(this.destroyRef)).subscribe({next:()=>{this.loading=!1,this.toastService.success(this.translateService.instant("The client is deleted")),this.removeClientFromList(t)},error:()=>{this.toastService.error(this.translateService.instant("The client could not be deleted"))}}))})}approveDisabled(t,n){return!t||!n.isSuperadmin()||t.password===""||t.fingerprint===""?!0:t.systemName===""}onApprove(t,n,e){if(!n.isSuperadmin()||!t||t.password===""||!t.systemName)return;this.publicPageService.approve(e,t).pipe(at(this.destroyRef)).subscribe({next:()=>{this.toastService.success(this.translateService.instant("The client is approved")),t.approved=!0},error:()=>{this.toastService.error(this.translateService.instant("The client could not be approved!"))}})}onCopyUrl(t){let n=this.getUrl(t);navigator.clipboard.writeText(n)}getLanguageFlagKey(t){return this.translationService.getLanguageFlagKey(t)}changeLanguage(t,n,e){if(!t)return;switch(e){case T.GERMAN:t.language=T.GERMAN;break;case T.CHINESE:t.language=T.CHINESE;break;case T.FRENCH:t.language=T.FRENCH;break;case T.ITALIAN:t.language=T.ITALIAN;break;case T.KOREAN:t.language=T.KOREAN;break;case T.TURKEY:t.language=T.TURKEY;break;case T.HUNGARY:t.language=T.HUNGARY;break;case T.PORTUGUESE:t.language=T.PORTUGUESE;break;default:t.language=T.ENGLISH}this.publicPageService.changeLanguage(t,n,e).pipe(at(this.destroyRef)).subscribe({next:()=>{this.toastService.success(this.translateService.instant("Client language saved"))},error:()=>{this.toastService.error(this.translateService.instant("The client language could not be saved!"))}})}showPrivatePassword(t){return t?.password?"***":this.translateService.instant("No entry")}getUrl(t){return"/public"+t}showPrivateFingerprint(t){return t?.fingerprint?this.translateService.instant("No entry"):"***"}isApproved(t){return t?t.approved:!1}loadPublicPages(t){this.loading=!0,this.adminTenantService.listPublicPages(t).subscribe({next:e=>{this.publicPages=e},error:e=>{console.log("Error loading public pages",e)},complete:()=>{this.loading=!1}})}reloadPublicPages(t){this.loading=!0,this.loadPublicPages(t)}removeClientFromList(t){let n=this.publicPages.findIndex(e=>e.publicPageClient===t);if(n!==-1){let e=this.publicPages[n];e.publicPageClient=void 0}}static{this.\u0275fac=function(n){return new(n||i)}}static{this.\u0275cmp=E({type:i,selectors:[["app-organization-public-pages"]],viewQuery:function(n,e){if(n&1&&H(L,5),n&2){let r;G(r=K())&&(e.headers=r)}},inputs:{currentUser:"currentUser",tenant:"tenant"},decls:10,vars:13,consts:[[1,"container-fluid"],[1,"row"],[1,"col-11"],[3,"heading","itemName","count","type"],[1,"col-1","mt-2"],[3,"absolute"],[1,"btn","btn-light","pull-right",3,"click","title"],[3,"icon"],[1,"col"],[1,"table-responsive"],[1,"table","table-striped"],["translate",""],["sortable","machineName",1,"sortable",3,"sort"],["sortable","label",1,"sortable",3,"sort"],["sortable","publicPageClient.systemName",1,"sortable",3,"sort"],["sortable","publicPageClient.password",1,"s
1ortable",3,"sort"],["sortable","publicPageClient.fingerprint",1,"sortable",3,"sort"],["sortable","publicPageClient.approved",1,"sortable",3,"sort"],[3,"new-public-client-row"],["data-cell-buttons","4"],["role","group",1,"btn-group"],["type","button",1,"btn","btn-sm","btn-light",3,"click","disabled","ngbTooltip"],["type","button",1,"btn","btn-sm","btn-light",3,"click","ngbTooltip"],["ngbDropdown","","container","body","ngbDropdownToggle","",1,"btn","btn-sm","btn-light","dropdown-toggle-without-caret","pt-1","pb-1",3,"ngbTooltip"],["type","button","ngbDropdownAnchor","",1,"btn","btn-light","dropdown-toggle-without-caret","align-middle"],["ngbDropdownMenu","","aria-labelledby","dropdownLanguage",1,"dropdown-menu","dropdown-menu-end"],["translate","",1,"dropdown-header"],["ngbDropdownItem","",1,"",3,"ngClass"],["ngbDropdownItem","",1,"",3,"click","ngClass"],[1,"float-end"]],template:function(n,e){n&1&&(a(0,"div",0)(1,"div",1)(2,"div",2),C(3,"app-admin-config-page-header",3),b(4,"translate"),b(5,"translate"),b(6,"translate"),o(),g(7,mi,4,5,"div",4),o(),g(8,di,1,1,"ab-loading-spinner",5),g(9,fi,29,0,"div",1),o()),n&2&&(s(3),m("heading",S(4,7,"Organization"))("itemName",e.tenant?e.tenant.name:"")("count",e.publicPages?e.publicPages.length:0)("type",e.publicPages&&e.publicPages.length===1?S(5,9,"Public page"):S(6,11,"Public pages")),s(4),_(e.tenant?7:-1),s(),_(e.loading?8:-1),s(),_(e.tenant&&e.currentUser&&!e.loading?9:-1))},dependencies:[U,D,F,I,nt,j,$,L,Ve,ve,he,Ce,fe,_e,Ot,V],encapsulation:2})}}return i})();var hi=i=>({"is-invalid":i});function Ci(i,c){i&1&&C(0,"ab-loading-spinner",10),i&2&&m("absolute",!1)}function vi(i,c){i&1&&(a(0,"span",15),l(1,"Number value required!"),o())}function bi(i,c){i&1&&(a(0,"span",15),l(1,"Please enter a non-negative number!"),o())}function Si(i,c){if(i&1){let t=y();a(0,"form",null,0)(2,"p",9),l(3,"Specify the maximum number of WhatsApp messages that can be sent to users of this organization per month."),o(),a(4,"div",11)(5,"div",12)(6,"input",13,1),B("ngModelChange",function(e){d(t);let r=p();return k(r.maximumWhatsAppMessages,e)||(r.maximumWhatsAppMessages=e),u(e)}),o(),a(8,"small",14)(9,"span",9),l(10,"Messages this month:"),o(),l(11),o(),g(12,vi,2,0,"span",15),g(13,bi,2,0,"span",15),o()(),a(14,"button",16),h("click",function(){d(t);let e=p();return u(e.onSave())}),l(15," Save "),o()()}if(i&2){let t=Q(1),n=Q(7),e=p();s(6),m("ngClass",X(6,hi,n.touched&&n.invalid)),z("ngModel",e.maximumWhatsAppMessages),s(5),w(" ",e.messageCountThisMonth),s(),_(n.hasError("required")?12:-1),s(),_(n.hasError("min")?13:-1),s(),m("disabled",e.disableSaveButton(t))}}var Ye=(()=>{class i{constructor(){this.maximumWhatsAppMessages=0,this.messageCountThisMonth=0,this.initialValue=0,this.darkMode=!1,this.toastService=f(W),this.translateService=f(R),this.adminTenantService=f(Y)}ngOnInit(){this.darkMode=xt(),this.loadWhatsAppLimits()}loadWhatsAppLimits(){if(!this.tenant)return;this.adminTenantService.getWhatsAppMessageLimit(this.tenant.id).subscribe({next:n=>{this.maximumWhatsAppMessages=n.maximumWhatsAppMessages,this.messageCountThisMonth=n.messageCountThisMonth,this.initialValue=this.maximumWhatsAppMessages},error:()=>{this.toastService.error(this.translateService.instant("There is an error loading organization WhatsApp limits"))}})}onSave(){if(!this.tenant||this.maximumWhatsAppMessages===void 0)return;this.adminTenantService.saveWhatsAppMessageLimit(this.tenant,this.maximumWhatsAppMessages).subscribe({next:()=>{this.toastService.success(this.translateService.instant("WhatsApp Message Limit saved!"))},error:()=>{this.toastService.error(this.translateService.instant("Error saving WhatsApp limit. Please try again!"))}})}disableSaveButton(t){return this.initialValue===this.maximumWhatsAppMessages?!0:!!t.invalid}static{this.\u0275fac=function(n){return new(n||i)}}static{this.\u0275cmp=E({type:i,selectors:[["app-organization-whats-app-limit"]],inputs:{tenant:"tenant"},decls:13,vars:7,consts:[["whatsAppLimitForm","ngForm"],["whatsAppLimit","ngModel"],[1,"container-fluid"],[1,"row"],[1,"col-12","col-sm-6"],[1,"page-header","page-header-subhead"],[1,"title-wrapper"],[1,"h3",3,"ngClass"],[1,"details"],["translate",""],[3,"absolute"],[1,"col-6"],[1,"form-group"],["name","whatsAppLimit","id","whatsAppLimit","type","number","min","0","required","",1,"form-control",3,"ngModelChange","ngClass","ngModel"],[1,"pull-right"],["translate","",1,"invalid-feedback"],["translate","",1,"btn","btn-primary",3,"click","disabled"]],template:function(n,e){n&1&&(a(0,"div",2)(1,"div",3)(2,"div",4)(3,"div",5)(4,"div",6)(5,"h1",7),l(6),b(7,"translate"),o(),a(8,"div",8)(9,"span",9),l(10,"WhatsApp Message Limits"),o()()()()()(),g(11,Ci,1,1,"ab-loading-spinner",10),g(12,Si,16,8,"form"),o()),n&2&&(s(5),m("ngClass",e.darkMode?"text-secondary":"text-primary"),s(),Vt("",S(7,5,"Organization"),"",e.tenant?" "+e.tenant.name:""),s(5),_(e.tenant?-1:11),s(),_(e.tenant?12:-1))},dependencies:[U,D,F,I,$,bt,lt,rt,At,Z,st,kt,zt,ht,mt,V],encapsulation:2})}}return i})();var gt=class i{constructor(c){this.label="",this.languageKeyTranslationMap=new Map,this.languageKeyModifiedMap=new Map,c&&(Object.assign(this,c),this.fillTranslationMap(),this.fillModifiedMap())}searchTermIncluded(c){let t=c.toUpperCase();return this.label.toUpperCase().includes(t)}fillTranslationMap(){if(this.languageKeyTranslationMap instanceof Map)return;let c=new Map;for(let t in this.languageKeyTranslationMap){let n=this.languageKeyTranslationMap[t];c.set(t,n)}this.languageKeyTranslationMap=c}fillModifiedMap(){if(this.languageKeyModifiedMap instanceof Map)return;let c=new Map;for(let t in this.languageKeyModifiedMap){let n=this.languageKeyModifiedMap[t];c.set(t,n)}this.languageKeyModifiedMap=c}createEntryWithJsonMaps(){let c=new i(void 0);return c.id=this.id,c.label=this.label,c.translationCategory=this.translationCategory,this.languageKeyTranslationMap instanceof Map&&(c.languageKeyTranslationMap=Object.assign({},...Array.from(this.languageKeyTranslationMap.entries()).map(([t,n])=>({[t]:n})))),this.languageKeyModifiedMap instanceof Map&&(c.languageKeyModifiedMap=Object.assign({},...Array.from(this.languageKeyModifiedMap.entries()).map(([t,n])=>({[t]:n})))),c}};var Je=(()=>{class i{refresh(){return this.http.get("/api/web/updateTranslationTables")}constructor(){this.http=f(ce),this.BASE_URL="/api/web/admin/tenant/"}getBaseUrl(t){return this.BASE_URL+t.id+"/translation"}getTranslations(t){let n=this.getBaseUrl(t);return this.http.get(n).pipe(ie(e=>e.map(r=>new gt(r))))}save(t,n){let e=this.getBaseUrl(n),r=[];for(let v of t)r.push(v.createEntryWithJsonMaps());let x={translationEntryList:r};return this.http.post(e,x)}static{this.\u0275fac=function(n){return new(n||i)}}static{this.\u0275prov=_t({token:i,factory:i.\u0275fac,providedIn:"root"})}}return i})();var ee=(function(i){return i.FRONTEND_LABEL="FRONTEND_LABEL",i.SIGNAL="SIGNAL",i.MACHINE="MACHINE",i.TENANT="TENANT",i.GATEWAY="GATEWAY",i.GROUP="GROUP",i.PAGE="PAGE",i.WIDGET="WIDGET",i.CONSTANT="CONSTANT",i.IMPORT="IMPORT",i})(ee||{});function xi(i,c){if(i&1&&(a(0,"form",0),C(1,"input",1),o()),i&2){let t,n=p();m("formGroup",n.translationEntry),s(),m("ngClass",(t=n.translationEntry.get("modified"))!=null&&t.value?"bg-danger bg-opacity-10":"transparent-background")}}var Xe=(()=>
1{class i{constructor(){this.label="",this.code="en"}ngOnInit(){if(!this.form)return;let t=this.form.controls.translationEntries,n=this.findFormGroupOfLabel(t);n&&(this.translationEntry=n.controls[this.code],this.translationEntry.controls.translation.valueChanges.subscribe(e=>{if(this.translationEntry){if(!e){this.translationEntry.controls.modified.setValue(!1);return}if(e==""){this.translationEntry.controls.modified.setValue(!1);return}this.translationEntry.controls.translation.dirty&&this.translationEntry.controls.modified.setValue(!0)}}))}findFormGroupOfLabel(t){for(let n of t.controls){let e=n;if(e.controls.label.value===this.label)return e}}static{this.\u0275fac=function(n){return new(n||i)}}static{this.\u0275cmp=E({type:i,selectors:[["app-translation-entry"]],inputs:{label:"label",form:"form",code:"code"},decls:1,vars:1,consts:[[3,"formGroup"],["type","text","formControlName","translation",1,"form-control",3,"ngClass"]],template:function(n,e){n&1&&g(0,xi,2,2,"form",0),n&2&&_(e.form&&e.translationEntry?0:-1)},dependencies:[U,D,St,lt,rt,Z,st,vt,Ct],encapsulation:2})}}return i})();var Ti=()=>({prefix:"far",iconName:"refresh"}),yi=()=>({prefix:"far",iconName:"upload"}),Ei=()=>({prefix:"far",iconName:"download"}),Ze=(i,c)=>c.key,wi=(i,c)=>c.id;function Mi(i,c){if(i&1){let t=y();a(0,"div",5)(1,"div",7)(2,"app-search-input",8),b(3,"translate"),B("searchTermChange",function(e){d(t);let r=p(2);return k(r.searchTerm,e)||(r.searchTerm=e),u(e)}),h("searchTermChange",function(){d(t);let e=p(2);return u(e.filterLabel())}),o(),a(4,"div",9)(5,"button",10),h("click",function(){d(t);let e=p(2);return u(e.refresh())}),C(6,"fa-icon",11),a(7,"span",12),l(8,"Refresh"),o()(),a(9,"button",13),h("click",function(){d(t);let e=Q(14);return u(e.click())}),C(10,"fa-icon",11),a(11,"span",12),l(12,"Import translations"),o()(),a(13,"input",14,0),h("change",function(e){d(t);let r=p(2);return u(r.importLanguageJSON(e))}),o(),a(15,"button",15),h("click",function(){d(t);let e=p(2);return u(e.exportTranslations())}),C(16,"fa-icon",11),a(17,"span",12),l(18,"Export translations"),o()(),a(19,"button",16),h("click",function(){d(t);let e=p(2);return u(e.save())}),a(20,"span",17),l(21,"Save"),o()()()()()}if(i&2){let t=p(2);s(2),m("inputLabel",q(S(3,8,"Search label..."))),z("searchTerm",t.searchTerm),s(4),m("icon",M(10,Ti)),s(3),m("ngClass",t.darkMode?"btn-outline-secondary":"btn-outline-primary"),s(),m("icon",M(11,yi)),s(5),m("ngClass",t.darkMode?"btn-outline-secondary":"btn-outline-primary"),s(),m("icon",M(12,Ei))}}function Ii(i,c){i&1&&C(0,"ab-loading-spinner",6),i&2&&m("absolute",!1)}function Vi(i,c){if(i&1&&(a(0,"th"),l(1),b(2,"translate"),o()),i&2){let t=c.$implicit;s(),O(S(2,1,t.key))}}function Fi(i,c){if(i&1&&(a(0,"td"),C(1,"app-translation-entry",26),o()),i&2){let t=c.$implicit,n=p().$implicit,e=p(3);s(),m("code",t.value)("form",e.translationForm)("label",n.label)}}function Ni(i,c){if(i&1&&(a(0,"tr")(1,"td"),l(2),o(),P(3,Fi,2,3,"td",null,Ze),b(5,"keyvalue"),o()),i&2){let t=c.$implicit,n=p(3);s(2),w(" ",t.label," "),s(),A(Qt(5,1,n.Language,n.originalOrder))}}function Oi(i,c){if(i&1&&(a(0,"ng-option",25),l(1),o()),i&2){let t=c.$implicit;m("value",t),s(),w(" ",t," ")}}function Pi(i,c){if(i&1){let t=y();a(0,"div",2)(1,"div",18)(2,"div",19)(3,"table",20)(4,"thead")(5,"tr")(6,"th",21),h("sort",function(e){d(t);let r=p(2);return u(r.onSort(e))}),a(7,"span",17),l(8,"Label"),o()(),P(9,Vi,3,3,"th",null,Ze),b(11,"keyvalue"),o()(),a(12,"tbody"),P(13,Ni,6,4,"tr",null,wi),b(15,"slice"),o(),a(16,"tfoot")(17,"td",22)(18,"ngb-pagination",23),B("pageChange",function(e){d(t);let r=p(2);return k(r.page,e)||(r.page=e),u(e)}),o(),a(19,"div")(20,"span",17),l(21,"Display"),o(),a(22,"ng-select",24),B("ngModelChange",function(e){d(t);let r=p(2);return k(r.pageSize,e)||(r.pageSize=e),u(e)}),P(23,Oi,2,2,"ng-option",25,ot),o()()()()()()()()}if(i&2){let t=p(2);s(9),A(Qt(11,6,t.Language,t.originalOrder)),s(4),A(oe(15,9,t.filteredTranslations,(t.page-1)*t.pageSize,t.page*t.pageSize)),s(5),z("page",t.page),m("pageSize",t.pageSize)("collectionSize",t.filteredTranslations.length)("maxSize",4)("boundaryLinks",!0),s(4),z("ngModel",t.pageSize),s(),A(t.itemsPerPageOptions)}}function Ai(i,c){if(i&1&&(a(0,"div",1)(1,"div",2)(2,"div",3),C(3,"app-admin-config-page-header",4),b(4,"translate"),b(5,"translate"),o(),g(6,Mi,22,13,"div",5),o(),g(7,Ii,1,1,"ab-loading-spinner",6),g(8,Pi,25,13,"div",2),o()),i&2){let t=p();s(3),m("heading",S(4,7,"Organization"))("itemName",t.tenant?t.tenant.name:"")("count",t.translationEntries.length)("type",S(5,9,"Translations")),s(3),_(t.tenant?6:-1),s(),_(!t.tenant||t.loading?7:-1),s(),_(t.tenant&&!t.loading?8:-1)}}var tn=(()=>{class i{constructor(){this.translationEntries=[],this.filteredTranslations=[],this.translationForm=new ut({}),this.page=1,this.pageSize=25,this.itemsPerPageOptions=[5,10,20,50,100,500,1e3],this.loading=!1,this.searchTerm="",this.darkMode=!1,this.Languages=[T.GERMAN,T.ENGLISH,T.FRENCH,T.ITALIAN,T.KOREAN,T.HUNGARY,T.TURKEY,T.CHINESE,T.PORTUGUESE],this.Language=T,this.organizationTranslationsService=f(Je),this.tableSortService=f(et),this.fb=f(ue),this.toastService=f(W),this.translateService=f(R),this.destroyRef=f(ft),this.originalOrder=(t,n)=>0,this.translationForm=this.generateForm()}ngOnInit(){if(this.darkMode=xt(),!this.tenant)return;this.loading=!0,this.organizationTranslationsService.getTranslations(this.tenant).pipe(at(this.destroyRef)).subscribe({next:n=>{this.translationEntries=n,this.fillForm(),this.loading=!1,setTimeout(()=>{this.tableSortService.initialSortTableItems(this.translationEntries,"label","asc",this.headers),this.filterLabel()})},error:()=>{console.log("Error loading translation entries"),this.loading=!1}})}onSort({column:t,direction:n}){this.headers&&this.tableSortService.sortTableItems(this.filteredTranslations,t,n,this.headers)}filterLabel(){this.filteredTranslations=this.translationEntries.filter(t=>t.searchTermIncluded(this.searchTerm))}save(){if(!this.tenant)return;let t=this.writeFormToEntries();this.organizationTranslationsService.save(t,this.tenant).pipe(at(this.destroyRef)).subscribe({next:()=>{this.toastService.success(this.translateService.instant("The translations are saved"))},error:e=>{this.toastService.error(this.translateService.instant("Error on saving the translations")),console.log(e)}})}generateForm(){return this.fb.group({translationEntries:this.fb.array([])})}updateEntryInForm(t,n,e){let r=this.translationForm.controls.translationEntries;for(let x of r.controls){let v=x;if(t===v.controls.label.value){let N=v.controls[e];if(N.controls.modified.value===!0)return;let ne=N.controls.translation.value!==n;N.controls.translation.setValue(n),N.controls.modified.setValue(ne)}}}addNewEntryToForm(t){let n=this.translationForm.controls.translationEntries,e=n.controls.length;n.insert(e,this.createTranslationEntryFormGroup(t))}fillForm(){let t=this.translationForm.controls.translationEntries;for(let n of this.translationEntries){let e=t.controls.length;t.insert(e,this.createTranslationEntryFormGroup(n))}}exportTranslations(){let t=this.translateService.getCurrentLang(),n={};for(let v of this.translationEntries){let N=v.label;if(v.languageKeyTranslationMap instanceof Map){let it=v.languageKeyTranslationMap.get(t);n[N]=it??""}}let e=JSON.stringify(n,null,2),r="data:application/json;charset=utf-8,"+encodeURIComponent(e),x=document.createElement("a");x.href=r,x.target="_blank",x.download=t+".json",x.click()}generateTranslationForm(t,n,e){return this.fb.group({translation:[t],modified:[n],label:[e]})}importTranslations(t){let n=this.translateService.getCurrentLang();for(let e of t.entries())this.updateEntry(e,n);this.filteredTranslations=this.translationEntries,setTimeout(()=>{this.tableSortService.initialSortTableItems(this.translationEntries,"label","asc",this.headers),this.filterLabel()})}importLanguageJSON(t){if(!t.target)return;let n=t.target,e=new FileReader;if(e.onload=x=>{try{if(typeof e.result=="string"){let v=JSON.parse(e.result),N=this.getStringMap(v);this.importTranslations(N)}else{this.toastService.error("Invalid JSON");return}}catch(v){console.log(v),this.toastService.error("Invalid JSON");return}finally{n.value=""}},!n.files)return;let r=n.files[0];e.readAsText(r)}createTranslationEntryFormGroup(t){return this.fb.group({label:t.label,id:t.id,category:t.translationCategory,de:this.generateTranslationForm(t.languageKeyTranslationMap.get(T.GERMAN),t.languageKeyModifiedMap.get(T.GERMAN),t.label),en:this.generateTranslationForm(t.languageKeyTranslationMap.get(T.ENGLISH),t.languageKeyModifiedMap.get(T.ENGLISH),t.label),fr:this.generateTranslationForm(t.languageKeyTranslationMap.get(T.FRENCH),t.languageKeyModifiedMap.get(T.FRENCH),t.label),it:this.generateTranslationForm(t.languageKeyTranslationMap.get(T.ITALIAN),t.languageKeyModifiedMap.get(T.ITALIAN),t.label),tr:this.generateTranslationForm(t.languageKeyTranslationMap.get(T.TURKEY),t.languageKeyModifiedMap.get(T.TURKEY),t.label),hu:this.generateTranslationForm(t.languageKeyTranslationMap.get(T.HUNGARY),t.languageKeyModifiedMap.get(T.HUNGARY),t.label),ko:this.generateTranslationForm(t.languageKeyTranslationMap.get(T.KOREAN),t.languageKeyModifiedMap.get(T.KOREAN),t.label),zh:this.generateTranslationForm(t.languageKeyTranslationMap.get(T.CHINESE),t.languageKeyModifiedMap.get(T.CHINESE),t.label),pt:this.generateTranslationForm(t.languageKeyTranslationMap.get(T.PORTUGUESE),t.languageKeyModifiedMap.get(T.PORTUGUESE),t.label)})}updateEntry(t,n){for(let r of this.translationEntries)if(r.label===t[0]){if(r.languageKeyModifiedMap instanceof Map&&r.languageKeyModifiedMap.get(n)===!0)return;if(r.languageKeyTranslationMap instanceof Map){if(!t[1]||t[1]==="")return;r.languageKeyTranslationMap.set(n,t[1]),this.updateEntryInForm(r.label,t[1],n);return}}let e=new gt(void 0);e.label=t[0],e.translationCategory=ee.IMPORT,e.languageKeyTranslationMap=new Map,e.languageKeyTranslationMap.set(n,t[1]),e.languageKeyModifiedMap=new Map,e.languageKeyModifiedMap.set(n,!0),this.translationEntries.push(e),this.addNewEntryToForm(e)}getStringMap(t){if(t instanceof Map)return t;let n=new Map;for(let e in t){let r=t[e];n.set(e,r)}return n}writeFormToEntries(){let t=this.translationForm.controls.translationEntries,n=[];for(let e of t.controls){let r=e;this.entryIsModified(r)&&n.push(this.writeFormToEntry(r))}return n}writeFormToEntry(t){let n=t.controls.label.value,e=t.controls.id.value,r=new gt(void 0);r.id=e,r.label=n,r.translationCategory=t.controls.category.value,r.languageKeyModifiedMap=new Map,r.languageKeyTranslationMap=new Map;for(let x of this.Languages)this.addLanguageSpecificFieldsFromForm(r,t,x);return r}addLanguageSpecificFieldsFromForm(t,n,e){let r=n.controls[e],x=r.controls.modified.value,v=r.controls.translation.value;t.languageKeyTranslationMap.set(e,v),t.languageKeyModifiedMap.set(e,x)}entryIsModified(t){for(let n of this.Languages)if(this.entryIsModifiedByLanguage(n,t))return!0;return!1}entryIsModifiedByLanguage(t,n){return n.controls[t].controls.modified.value}refresh(){this.organizationTranslationsService.refresh().pipe(at(this.destroyRef)).subscribe({next:()=>{},error:n=>{console.log("failed "+n)}})}static{this.\u0275fac=function(n){return new(n||i)}}static{this.\u0275cmp=E({type:i,selectors:[["app-translations"]],viewQuery:function(n,e){if(n&1&&H(L,5),n&2){let r;G(r=K())&&(e.headers=r)}},inputs:{tenant:"tenant"},decls:1,vars:1,consts:[["fileInput",""],[1,"container-fluid"],[1,"row"],[1,"col-12","col-md-4"],[3,"heading","itemName","count","type"],[1,"col-12","col-md-8"],[3,"absolute"],[1,"admin-page-buttons","btn-toolbar"],[3,"searchTermChange","searchTerm","input
1Label"],[1,"admin-page-btn-group"],[1,"btn","btn-primary",3,"click"],[3,"icon"],["translate","",1,"d-none","d-xl-inline"],["type","button","id","importTranslations",1,"btn",3,"click","ngClass"],["type","file",1,"d-none",3,"change"],["type","button","id","exportTranslations",1,"btn",3,"click","ngClass"],["type","button",1,"btn","btn-primary",3,"click"],["translate",""],[1,"col"],[1,"table-responsive"],[1,"table","table-striped"],["sortable","label",1,"sortable",3,"sort"],["colspan","3"],[1,"pt-0","pb-0",3,"pageChange","page","pageSize","collectionSize","maxSize","boundaryLinks"],["name","pageSize",1,"form-control",3,"ngModelChange","ngModel"],[3,"value"],[3,"code","form","label"]],template:function(n,e){n&1&&g(0,Ai,9,11,"div",1),n&2&&_(e.tenant?0:-1)},dependencies:[U,D,F,I,nt,bt,Z,ht,j,$,L,Xe,Ie,Wt,Ae,ke,le,Ot,V],encapsulation:2})}}return i})();var zi=()=>({prefix:"far",iconName:"angle-left"});function ki(i,c){if(i&1&&(a(0,"h1",6)(1,"span"),l(2),b(3,"translate"),o()()),i&2){let t=p();m("ngClass",t.darkMode?"text-secondary":"text-primary"),s(2),Vt("",S(3,3,"Organization")," ",t.tenant.name)}}function Di(i,c){if(i&1&&C(0,"app-organization-machines",20),i&2){let t=p();m("tenant",t.tenant)}}function Ui(i,c){if(i&1&&C(0,"app-organization-users",20),i&2){let t=p(2);m("tenant",t.tenant)}}function Li(i,c){i&1&&(a(0,"li",13)(1,"a",11),l(2,"Users"),o(),pt(3,Ui,1,1,"ng-template",12),o())}function Bi(i,c){if(i&1&&C(0,"app-organization-contacts",21),i&2){let t=p();m("contacts",t.tenantContacts)("currentUser",t.currentUser)("tenant",t.tenant)}}function Ri(i,c){if(i&1&&C(0,"app-organization-constants",22),i&2){let t=p();m("currentUser",t.currentUser)("tenant",t.tenant)}}function Wi(i,c){if(i&1&&C(0,"app-organization-public-pages",22),i&2){let t=p();m("currentUser",t.currentUser)("tenant",t.tenant)}}function Gi(i,c){if(i&1&&C(0,"app-organization-whats-app-limit",20),i&2){let t=p(2);m("tenant",t.tenant)}}function Ki(i,c){i&1&&(a(0,"li",17)(1,"a",11),l(2,"WhatsApp limits"),o(),pt(3,Gi,1,1,"ng-template",12),o())}function qi(i,c){if(i&1&&C(0,"app-translations",20),i&2){let t=p(2);m("tenant",t.tenant)}}function Hi(i,c){i&1&&(a(0,"li",18)(1,"a",11),l(2,"Translations"),o(),pt(3,qi,1,1,"ng-template",12),o())}var bs=(()=>{class i{constructor(){this.toastService=f(W),this.titleService=f(pe),this.translateService=f(R),this.router=f(Fe),this.adminTenantService=f(Y),this.route=f(Tt),this.userService=f(Ne),this.helperService=f(tt),this.tenantId=-1,this.tenantContacts=[],this.active="machines",this.darkMode=!1,this.destroyRef=f(ft)}ngOnInit(){this.darkMode=xt();let t=this.route.snapshot.paramMap.get("tenantId");t&&(this.tenantId=parseInt(t),this.loadTenant(),this.loadCurrentUser())}loadTenant(){this.adminTenantService.get(this.tenantId).pipe(at(this.destroyRef)).subscribe({next:t=>{this.tenant=t,this.titleService.setTitle(this.translateService.instant("Organization")+" "+t.name+" - "+re.PortalSettings.portalTitle)},error:()=>{this.toastService.error(this.translateService.instant("The organization could not be loaded!"))}})}loadCurrentUser(){this.userService.get().pipe(at(this.destroyRef)).subscribe({next:t=>{this.currentUser=t},error:()=>{this.toastService.error(this.translateService.instant("There is an error in getting current user details"))}})}isSuperAdminRole(){return this.currentUser?this.currentUser.isSuperadmin():!1}isAdminRole(){return this.currentUser?this.currentUser.hasAdminRole():!1}onBackClick(){let t=this.route.snapshot.queryParamMap.get("search");this.helperService.onBackClick(this.router,t)}static{this.\u0275fac=function(n){return new(n||i)}}static{this.\u0275cmp=E({type:i,selectors:[["app-organization-config"]],decls:30,vars:9,consts:[["nav","ngbNav"],[1,"container-fluid"],[1,"page-header"],[1,"title-wrapper"],[1,"btn","back-button",3,"click","ngClass"],[3,"icon"],[1,"h3","config-header",3,"ngClass"],[1,"row"],[1,"col-lg-2"],["ngbNav","","orientation","vertical",1,"nav-pills",3,"activeIdChange","activeId"],["ngbNavItem","machines"],["ngbNavLink","","translate",""],["ngbNavContent",""],["ngbNavItem","users"],["ngbNavItem","support"],["ngbNavItem","constants"],["ngbNavItem","publicPages"],["ngbNavItem","waLimits"],["ngbNavItem","translationTable"],[1,"col-lg-10",3,"ngbNavOutlet"],[3,"tenant"],[3,"contacts","currentUser","tenant"],[3,"currentUser","tenant"]],template:function(n,e){if(n&1){let r=y();a(0,"div",1)(1,"div",2)(2,"div",3)(3,"a",4),h("click",function(){return e.onBackClick()}),C(4,"fa-icon",5),o(),g(5,ki,4,5,"h1",6),o()(),a(6,"div",7)(7,"div",8)(8,"ul",9,0),B("activeIdChange",function(v){return d(r),k(e.active,v)||(e.active=v),u(v)}),a(10,"li",10)(11,"a",11),l(12,"Assets"),o(),pt(13,Di,1,1,"ng-template",12),o(),g(14,Li,4,0,"li",13),a(15,"li",14)(16,"a",11),l(17,"Supp
1ort contacts"),o(),pt(18,Bi,1,3,"ng-template",12),o(),a(19,"li",15)(20,"a",11),l(21,"Organization constants"),o(),pt(22,Ri,1,2,"ng-template",12),o(),a(23,"li",16)(24,"a",11),l(25,"Public pages"),o(),pt(26,Wi,1,2,"ng-template",12),o(),g(27,Ki,4,0,"li",17),g(28,Hi,4,0,"li",18),o()(),C(29,"div",19),o()()}if(n&2){let r=Q(9);s(3),m("ngClass",e.darkMode?"btn-outline-secondary":"btn-outline-primary"),s(),m("icon",M(8,zi)),s(),_(e.tenant?5:-1),s(3),z("activeId",e.active),s(6),_(e.currentUser!=null&&e.currentUser.hasAdminRole()?14:-1),s(13),_(e.isSuperAdminRole()?27:-1),s(),_(e.isAdminRole()?28:-1),s(),m("ngbNavOutlet",r)}},dependencies:[U,D,F,I,j,Me,be,Te,xe,Se,Ee,ye,we,Ue,Le,We,je,$e,Ye,tn,V],encapsulation:2})}}return i})();export{bs as OrganizationConfigComponent};
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.