import{Hc as x,ee as b}from"./chunk-NVJ2ZZFT.js";import{Aa as d,De as y,S as p,Te as S,ab as m,af as _,cb as C,db as E,dd as V,mg as T,ya as h,za as f}from"./chunk-SKPDQO4E.js";var o;(function(t){t[t.Brand=1]="Brand",t[t.Model=2]="Model",t[t.ColorCode=3]="ColorCode",t[t.VehicleType=4]="VehicleType",t[t.VisitorRegistrationPoint=5]="VisitorRegistrationPoint",t[t.OrganizationUnitType=6]="OrganizationUnitType"})(o||(o={}));var r;(function(t){t[t.String=1]="String",t[t.Number=2]="Number",t[t.Date=3]="Date",t[t.KeyValue=4]="KeyValue",t[t.JSON=5]="JSON"})(r||(r={}));var O=[{title:"ORGANIZATIONUNIT.ORG_TYPE",type:o.OrganizationUnitType,valueType:r.JSON},{title:"CREDENTIAL.TITLE_VEHICLE_TYPE",type:o.VehicleType,valueType:r.String},{title:"CREDENTIAL.TITLE_VEHICLE_BRAND",type:o.Brand,valueType:r.String},{title:"CREDENTIAL.TITLE_VEHICLE_MODEL",type:o.Model,relatedTypeTitle:"CREDENTIAL.TITLE_VEHICLE_BRAND",relatedType:o.Brand,valueType:r.String},{title:"CREDENTIAL.TITLE_VEHICLE_COLOR",type:o.ColorCode,valueType:r.String}];var I=function(t,e,i,a){var l=arguments.length,n=l<3?e:a===null?a=Object.getOwnPropertyDescriptor(e,i):a,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(t,e,i,a);else for(var c=t.length-1;c>=0;c--)(s=t[c])&&(n=(l<3?s(n):l>3?s(e,i,n):s(e,i))||n);return l>3&&n&&Object.defineProperty(e,i,n),n},u=class{languageService;constructor(e){this.languageService=e}transform(e){let i=Object.keys(e).find(a=>a.indexOf("_"+this.languageService.selectedLanguageCode)>-1);return i?e[i]:e[Object.keys(e).find(a=>a.indexOf("_")>-1)]}static ctorParameters=()=>[{type:_}]};u=I([f({name:"languageTranslate",standalone:!0})],u);var v=`<select [(ngModel)]="selectedValue" (ngModelChange)="onModelChanged($event)" [disabled]="disabled"\r
    class="form-select form-select-sm">\r
    <ng-container *ngFor="let listValue of listValues">\r
        <ng-container [ngSwitch]="definedListItem.valueType">\r
            <!-- STRING -->\r
            <ng-container *ngSwitchCase="1">\r
                <option [ngValue]="listValue">\r
                    {{listValue.value|translate}}\r
                </option>\r
            </ng-container>\r
            <!-- JSON -->\r
            <ng-container *ngSwitchCase="5">\r
                <ng-container [ngSwitch]="definedListItem.type">\r
                    <!-- ORG UNIT TYPE -->\r
                    <ng-container *ngSwitchCase="6">\r
                        <option [ngValue]="listValue.id">\r
                            {{listValue.value|languageTranslate}}\r
                        </option>\r
                    </ng-container>\r
                </ng-container>\r
            </ng-container>\r
        </ng-container>\r
    </ng-container>\r
</select>`;var R=`.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 L=function(t,e,i,a){var l=arguments.length,n=l<3?e:a===null?a=Object.getOwnPropertyDescriptor(e,i):a,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(t,e,i,a);else for(var c=t.length-1;c>=0;c--)(s=t[c])&&(n=(l<3?s(n):l>3?s(e,i,n):s(e,i))||n);return l>3&&n&&Object.defineProperty(e,i,n),n},P={provide:y,useExisting:p(()=>g),multi:!0},g=class{organizationUnitService;onChange;type;relatedType;relatedValueId;autoSelectFirstValue=!1;definedListItem;selectedValue;listValues;disabled=!0;constructor(e){this.organizationUnitService=e}writeValue(e){this.selectedValue=e}registerOnChange(e){this.onChange=e}registerOnTouched(e){}setDisabledState(e){}ngOnChanges(e){e.relatedValueId&&this.getData()}ngOnInit(){this.definedListItem=O.find(e=>e.type==this.type),this.getData()}onModelChanged(e){this.onChange(this.selectedValue)}getData(){if(this.type&&(!this.relatedType||this.relatedType&&this.relatedValueId)){let e=new x;e.type=this.type,this.relatedType&&this.relatedValueId&&(e.relatedValueId=this.relatedValueId),this.organizationUnitService.getUserDefinedList(e).subscribe(i=>{this.listValues=i.values,this.listValues&&this.listValues.length>=1?(this.disabled=!1,this.selectedValue=this.getSelectedValue(this.listValues),this.onChange(this.selectedValue)):(this.disabled=!0,this.onChange(null))})}else this.disabled=!0}getSelectedValue(e){if(this.selectedValue)switch(this.definedListItem.valueType){case r.String:return e.find(i=>i.value==this.selectedValue.value);case r.JSON:switch(this.definedListItem.type){case o.OrganizationUnitType:return e.find(i=>i.id==this.selectedValue).id}break}else return this.autoSelectFirstValue?e[0]:null}static ctorParameters=()=>[{type:b}];static propDecorators={type:[{type:d}],relatedType:[{type:d}],relatedValueId:[{type:d}],autoSelectFirstValue:[{type:d}]}};g=L([h({selector:"armon-user-defined-list-input",providers:[P],template:v,standalone:!0,imports:[S,T,m,C,E,u,V],styles:[R]})],g);export{o as a,r as b,O as c,u as d,g as e};
