import{a as k}from"./chunk-5DQKN4SL.js";import{Gb as M,X as T,hb as O,ib as F,rb as d}from"./chunk-YSQLW2JA.js";import"./chunk-NVJ2ZZFT.js";import{Aa as p,He as f,Nc as v,Pd as w,Qf as C,Se as b,Te as I,Ue as S,W as N,_a as A,ab as u,af as h,bb as c,dc as g,dd as m,ed as E,eh as U,gb as _,mg as P,ng as R,ya as l}from"./chunk-SKPDQO4E.js";var D=`<div class="row justify-content-center">
    <div class="col-xl-8 col-lg-12 col-md-12" *ngIf="userPreferences">

        <!-- USER INTERFACE -->
        <div class="row my-2">
            <div class="col-12">
                <div class="section-title color-primary">
                    <cds-icon shape="display" class="me-2 color-primary" size="lg"></cds-icon>
                    {{'MYACCOUNT.SECTION_USERINTERFACE_SETTINGS'|translate}}
                </div>
                <div class="col-12 py-3">
                    <div class="d-flex p-4 rounded-3 bg-white">
                        <armon-account-settings-userinterface [userPreferences]="userPreferences" class="w-100">
                        </armon-account-settings-userinterface>
                    </div>
                </div>
            </div>
        </div>
        <!-- END USER INTERFACE -->

        <!-- NOTIFICATIONS -->
        <div class="row">
            <div class="col-12">
                <div class="section-title color-primary">
                    <cds-icon shape="bell" class="me-2 color-primary" size="lg"></cds-icon>
                    {{'MYACCOUNT.SECTION_NOTIFICATION_SETTINGS'|translate}}
                </div>
                <div class="col-12 py-3">
                    <div class="d-flex p-4 rounded-3 bg-white">
                        <armon-notificationjobs-user-preferences class="w-100"
                            [notificationPreferences]="userPreferences.notification">
                        </armon-notificationjobs-user-preferences>
                    </div>
                </div>
            </div>
        </div>
        <!-- NOTIFICATIONS -->

    </div>
</div>`;var V=`<ng-container *ngIf="visible">
    <form [formGroup]="form">
        <div class="row">
            <div class="col-12 mb-3 pb-2 b-b-1">
                <span class="text-md">{{'NOTIFICATIONJOBS.ALL_TYPES_MEDIUM'|translate}}</span>
            </div>
            <div class="col-md-6 col-12 mb-3">
                <div class="w-100 d-flex flex-column p-3 shadow-box-1 rnd-1 bg-color-white">
                    <div class="d-flex align-items-end mb-1">
                        <label class="report-form-label">{{'NOTIFICATIONJOBS.MEDIUMS'|translate}}
                        </label>
                        <span *ngIf="noMedium" class="ms-auto text-danger text-xs">
                            <cds-icon shape="warning-standard" solid class="me-1"></cds-icon>
                            {{'NOTIFICATIONJOBS.NO_NOTIFICATION_TYPE'|translate}}
                        </span>
                    </div>
                    <armon-notification-medium-input [formControl]="form.get('mediumSettings').get('general')"
                        [validateModel]="false" [invalid]="form.get('mediumSettings').get('general').invalid">
                    </armon-notification-medium-input>
                    <ng-template
                        *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: form.get('mediumSettings'), control:form.get('mediumSettings').get('general'), isArray:true}">
                    </ng-template>
                </div>
            </div>
        </div>
        <div class="row px-2">
            <div class="col-12 d-flex align-items-center justify-content-between my-3 pb-2 b-b-1">
                <span class="text-md">{{'NOTIFICATIONJOBS.SPECIFIC_TYPE_MEDIUMS'|translate}}</span>
                <ng-template *ngTemplateOutlet="addCustomButtonTemplate">
                </ng-template>
            </div>
            <div class="col-12 mb-3">
                <div formArray="memberFilterFormUnits" [hidden]="formCustom.controls.length==0" class="row">
                    <ng-container
                        *ngFor="let formCustomControl of formCustom.controls; let index = index; let last = last;">
                        <div class="col-md-6 col-12 mb-3" [formGroup]="formCustomControl">
                            <div
                                class="w-100 d-flex flex-column p-3 shadow-box-1 rnd-1 bg-color-white position-relative">
                                <label class="report-form-label">{{'NOTIFICATIONJOBS.TYPE'|translate}}</label>
                                <nz-select class="w-100" nzSize="small"
                                    nzPlaceHolder="{{'COMMON.SELECT_ONE'|translate}}"
                                    [formControl]="formCustomControl.get('type')"
                                    [ngClass]="{'nz-invalid': formCustomControl.get('type').invalid}">
                                    <nz-option *ngFor="let notificationJobsType of notificationJobsTypes"
                                        [nzValue]="notificationJobsType.type"
                                        [nzLabel]="(notificationJobsType.title | translate)"></nz-option>
                                </nz-select>
                                <ng-template
                                    *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: formCustomControl, control:formCustomControl.get('type')}">
                                </ng-template>
                                <div class="d-flex align-items-end mb-1">
                                    <label class="report-form-label">{{'NOTIFICATIONJOBS.MEDIUMS'|translate}}
                                    </label>
                                    <span *ngIf="formCustomControl.noMedium" class="ms-auto text-danger text-xs">
                                        <cds-icon shape="warning-standard" solid class="me-1"></cds-icon>
                                        {{'NOTIFICATIONJOBS.NO_NOTIFICATION_TYPE'|translate}}
                                    </span>
                                </div>
                                <armon-notification-medium-input [formControl]="formCustomControl.get('mediums')"
                                    notificationType="{{formCustomControl.get('type').value}}" [validateModel]="false"
                                    [invalid]="formCustomControl.get('mediums').invalid">
                                </armon-notification-medium-input>
                                <ng-template
                                    *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: formCustomControl, control:formCustomControl.get('mediums'), isArray:true}">
                                </ng-template>
                                <div class="position-absolute" style="top: -6px; right: 4px;">
                                    <cds-icon solid class="ms-auto text-danger cursor-pointer" shape="times-circle"
                                        style="width: 20px; height: 20px;"
                                        (click)="onRemoveCustomClicked($event, index)"></cds-icon>
                                </div>
                            </div>
                        </div>
                    </ng-container>
                </div>
                <div class="col-12 d-flex flex-column row-gap-4 align-items-center justify-content-center py-5"
                    *ngIf="formCustom.controls.length==0">
                    <span
                        class="text-sm color-gray-dark fst-italic">{{'NOTIFICATIONJOBS.SPECIFIC_TYPE_SETTINGS'|translate}}</span>
                    <ng-template *ngTemplateOutlet="addCustomButtonTemplate">
                    </ng-template>
                </div>
            </div>
        </div>
    </form>
    <div class="row mt-3">
        <div class="col-12 d-flex justify-content-end">
            <button class="btn btn-sm btn-outline-primary me-2" *ngIf="drawerRef"
                (click)="onCancelClicked($event)">{{'BUTTON.CANCEL'|translate}}</button>
            <button class="btn btn-sm btn-success" [disabled]="form.invalid"
                (click)="onSaveClicked($event)">{{'BUTTON.SAVE'|translate}}</button>
        </div>
    </div>
</ng-container>

<!-- FORM FIELD VALIDATION -->
<ng-template #controlValidationTemplate let-form let-control="control" let-isArray="isArray">
    <ng-container *ngIf="control.errors">
        <div class="invalid-feedback" style="display: initial;">
            <span
                *ngIf="control.errors.required">{{(isArray?'VALIDATION.MIN_ONE_SELECTED':'VALIDATION.REQUIRED')|translate}}</span>
            <span *ngIf="control.errors.ip">{{'VALIDATION.IP_V4_OR_V6'|translate}}</span>
            <span *ngIf="control.errors.numeric">{{'VALIDATION.POSITIVE_NUMBER'|translate}}</span>
            <span *ngIf="control.errors.max">{{'VALIDATION.MAX_VALUE'|translate:control.errors.max}}</span>
            <span *ngIf="control.errors.unique">{{'VALIDATION.UNIQUE'|translate}}</span>
        </div>
    </ng-container>
</ng-template>

<ng-template #addCustomButtonTemplate>
    <button class="btn btn-sm btn-primary" (click)="onAddCustomClicked($event)">
        <cds-icon shape="plus-circle" solid class="cds-icon-18 me-1"></cds-icon>{{'BUTTON.ADD'|translate}}
    </button>
</ng-template>`;var j=`.justify-content-center{-webkit-box-pack:center;-moz-box-pack:center;-webkit-flex-pack:center;-ms-flex-pack:center;-moz-justify-content:center;-webkit-justify-content:center;justify-content:center}.justify-content-flex-end{-webkit-box-pack:end;-moz-box-pack:end;-webkit-flex-pack:end;-ms-flex-pack:end;-moz-justify-content:flex-end;-webkit-justify-content:flex-end;justify-content:flex-end}.card-footer{padding:.28rem .7rem}.alert{font-size:.756rem}@media screen and (min-width: 992px){.modal-xxl{max-width:1640px}}@media screen and (min-width: 1200px){.modal-xxxl{max-width:1860px}}.modal-fs{max-width:none;position:absolute;margin:auto;inset:16px;height:100vh;display:flex}.btn-link{text-decoration:none}.btn-link:hover{text-decoration:underline}.invalid-feedback{margin-top:0!important;font-size:.672rem!important}
`;var Y=function(s,e,t,i){var o=arguments.length,n=o<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(s,e,t,i);else for(var a=s.length-1;a>=0;a--)(r=s[a])&&(n=(o<3?r(n):o>3?r(e,t,n):r(e,t))||n);return o>3&&n&&Object.defineProperty(e,t,n),n},y=class{notificationJobService;interactionService;languageService;settingsService;drawerRef;formBuilder;visible=!1;form;notificationPreferences;notificationJobsTypes;noMedium;constructor(e,t,i,o,n,r){this.notificationJobService=e,this.interactionService=t,this.languageService=i,this.settingsService=o,this.drawerRef=n,this.formBuilder=r}ngOnInit(){}ngOnDestroy(){}ngAfterViewInit(){this.settingsService.getOrganizationSettings().subscribe(e=>{this.notificationJobsTypes=g(e.notification.enabledTypeDefs),this.notificationPreferences?this.createForm():this.getSettings()})}getSettings(){this.settingsService.getUserSettings().subscribe(e=>{this.notificationPreferences=e.notification,this.createForm()})}updateSettings(){let e=O.getEmptyModel(),t=F.getEmptyModel();Object.assign(t,this.form.value),e.notification=t,this.settingsService.updateUserSettings(e).subscribe(i=>{this.interactionService.showMessage("NOTIFICATIONJOBS.SETTINGS_USER_UPDATED",null,v.Success),this.drawerRef&&this.drawerRef.close()})}createForm(){if(this.form=this.formBuilder.group({mediumSettings:this.formBuilder.group({general:[this.notificationPreferences.mediumSettings.general?this.notificationPreferences.mediumSettings.general:null,f.required],custom:this.formBuilder.array([])})}),this.notificationPreferences.mediumSettings.custom&&this.notificationPreferences.mediumSettings.custom.length>0){let e=this.form.get("mediumSettings").get("custom");this.notificationPreferences.mediumSettings.custom.map(t=>{this.notificationJobsTypes.some(i=>i.type==t.type)&&e.push(this.createCustomUnitForm(t))})}this.form.get("mediumSettings").get("general").valueChanges.subscribe(e=>{this.noMedium=!this.hasAnySelected(e)}),this.visible=!0}get formCustom(){return this.form.get("mediumSettings").get("custom")}createCustomUnitForm(e=null){e||(e={});let t=this.formBuilder.group({type:[e.type?e.type:null,[f.required,R.unique()]],mediums:[e.mediums?e.mediums:null,f.required]});return t.get("mediums").valueChanges.subscribe(i=>{t.noMedium=!this.hasAnySelected(i)}),t}onAddCustomClicked(e){this.formCustom.push(this.createCustomUnitForm()),this.form.updateValueAndValidity()}onRemoveCustomClicked(e,t){this.formCustom.removeAt(t),this.form.updateValueAndValidity()}onCancelClicked(e){this.drawerRef&&this.drawerRef.close()}onSaveClicked(e){this.updateSettings()}hasAnySelected(e){return Object.keys(e).length>0&&!Object.keys(e).every(t=>e[t]==!1)}static ctorParameters=()=>[{type:T},{type:C},{type:h},{type:d},{type:k,decorators:[{type:N}]},{type:b}];static propDecorators={notificationPreferences:[{type:p}]}};y=Y([l({selector:"armon-notificationjobs-user-preferences",template:V,standalone:!0,imports:[c,I,S,P,M,_,u,U,A,m],styles:[j]})],y);var L=`<ng-container *ngIf="visible">
    <form [formGroup]="form">
        <div class="row">
            <div class="col-12 col-lg-6 mb-3">
                <label>{{'MYACCOUNT.PERSONAL_LANGUAGE_SETTING' | translate}}</label>
                <div class="select">
                    <select formControlName="locale" class="form-select form-select-sm">
                        <option *ngFor="let language of languages" [ngValue]="language.locale">
                            {{language.i18n | translate}}</option>
                    </select>
                </div>
            </div>
        </div>
    </form>
    <div class="row mt-3">
        <div class="col-12 d-flex justify-content-end">
            <button class="btn btn-sm btn-success" [disabled]="form.invalid"
                (click)="onSaveClicked($event)">{{'BUTTON.SAVE'|translate}}</button>
        </div>
    </div>
</ng-container>

<!-- FORM FIELD VALIDATION -->
<ng-template #controlValidationTemplate let-form let-control="control" let-isArray="isArray">
    <ng-container *ngIf="control.errors">
        <div class="invalid-feedback" style="display: initial;">
            <span
                *ngIf="control.errors.required">{{(isArray?'VALIDATION.MIN_ONE_SELECTED':'VALIDATION.REQUIRED')|translate}}</span>
            <span *ngIf="control.errors.ip">{{'VALIDATION.IP_V4_OR_V6'|translate}}</span>
            <span *ngIf="control.errors.numeric">{{'VALIDATION.POSITIVE_NUMBER'|translate}}</span>
            <span *ngIf="control.errors.max">{{'VALIDATION.MAX_VALUE'|translate:control.errors.max}}</span>
            <span *ngIf="control.errors.unique">{{'VALIDATION.UNIQUE'|translate}}</span>
        </div>
    </ng-container>
</ng-template>`;var B=`.justify-content-center{-webkit-box-pack:center;-moz-box-pack:center;-webkit-flex-pack:center;-ms-flex-pack:center;-moz-justify-content:center;-webkit-justify-content:center;justify-content:center}.justify-content-flex-end{-webkit-box-pack:end;-moz-box-pack:end;-webkit-flex-pack:end;-ms-flex-pack:end;-moz-justify-content:flex-end;-webkit-justify-content:flex-end;justify-content:flex-end}.card-footer{padding:.28rem .7rem}.alert{font-size:.756rem}@media screen and (min-width: 992px){.modal-xxl{max-width:1640px}}@media screen and (min-width: 1200px){.modal-xxxl{max-width:1860px}}.modal-fs{max-width:none;position:absolute;margin:auto;inset:16px;height:100vh;display:flex}.btn-link{text-decoration:none}.btn-link:hover{text-decoration:underline}.invalid-feedback{margin-top:0!important;font-size:.672rem!important}
`;var X=function(s,e,t,i){var o=arguments.length,n=o<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(s,e,t,i);else for(var a=s.length-1;a>=0;a--)(r=s[a])&&(n=(o<3?r(n):o>3?r(e,t,n):r(e,t))||n);return o>3&&n&&Object.defineProperty(e,t,n),n},x=class{notificationJobService;interactionService;languageService;settingsService;sessionService;formBuilder;visible=!1;form;userPreferences;languages;constructor(e,t,i,o,n,r){this.notificationJobService=e,this.interactionService=t,this.languageService=i,this.settingsService=o,this.sessionService=n,this.formBuilder=r}ngOnInit(){let e=g(E);this.languages=e}ngOnDestroy(){}ngAfterViewInit(){this.userPreferences?this.createForm():this.getSettings()}getSettings(){this.settingsService.getUserSettings().subscribe(e=>{this.userPreferences=e,this.createForm()})}updateSettings(){let e=O.getEmptyModel();Object.assign(e,this.form.value),this.settingsService.updateUserSettings(e).subscribe(t=>{this.languageService.setCurrentLanguage(e.locale),this.interactionService.showMessage("MYACCOUNT.SECTION_USERINTERFACE_SETTINGS_UPDATED",null,v.Success)})}createForm(){this.form=this.formBuilder.group({locale:[this.userPreferences.locale?this.userPreferences.locale:this.sessionService.sessionLanguageCode,f.required]}),this.visible=!0}onSaveClicked(e){this.updateSettings()}static ctorParameters=()=>[{type:T},{type:C},{type:h},{type:d},{type:w},{type:b}];static propDecorators={userPreferences:[{type:p}]}};x=X([l({selector:"armon-account-settings-userinterface",template:L,standalone:!0,imports:[c,I,S,u,m],styles:[B]})],x);var H=function(s,e,t,i){var o=arguments.length,n=o<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(s,e,t,i);else for(var a=s.length-1;a>=0;a--)(r=s[a])&&(n=(o<3?r(n):o>3?r(e,t,n):r(e,t))||n);return o>3&&n&&Object.defineProperty(e,t,n),n},z=class{settingsService;userPreferences;constructor(e){this.settingsService=e}ngOnInit(){this.getSettings()}ngOnDestroy(){}getSettings(){this.settingsService.getUserSettings().subscribe(e=>{this.userPreferences=e,console.log(this.userPreferences)})}static ctorParameters=()=>[{type:d}]};z=H([l({selector:"armon-account-settings",template:D,standalone:!0,imports:[c,x,y,m]})],z);export{z as AccountSettingsComponent};
