const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/KPopper-CuBnpfRA.js","assets/index-m7Z9H1b_.js"])))=>i.map(i=>d[i]); import{_ as x,d as L,ax as w,r as g,o as u,f as i,q as h,W as S,h as c,t as b,i as k,w as B,j as y,F as v,m as V,l as D,a as C}from"./index-m7Z9H1b_.js";import E from"./ButtonElement-VEOfE7ak.js";const O={name:"SelectInput",components:{ButtonElement:E,KPopper:L(()=>C(()=>import("./KPopper-CuBnpfRA.js"),__vite__mapDeps([0,1])))},props:{modelValue:{type:[String,Number,Boolean],default:null},id:{type:[String,Number],default:()=>`select-${Array.from(Array(20),()=>Math.floor(Math.random()*36).toString(36)).join("")}`},options:void 0,optionValue:void 0,optionLabel:{type:[String,Array,Function],default:null},sortKey:{type:String,default:"label"},sortOrder:{type:String,default:"asc"},sortOptions:{type:Boolean,default:!1},label:void 0,helpText:{type:String,default:null},showDefaultOption:{type:Boolean,default:!0},defaultValue:{type:[String,Number],default:""},defaultLabel:{type:String,default:"forms.select-default-label"},defaultDisabled:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},capitalizeLabel:{type:Boolean,default:!0},translateLabel:{type:Boolean,default:!0},vertical:{type:Boolean,default:!1},v:{type:Object,default:null},rowMargin:{type:String,default:"mb-3"},hasSlot:{type:Boolean,default:!1},btnDestroy:{type:[Function,Boolean],default:!1}},emits:["update:modelValue","blur"],computed:{conditionalOptions:({id:t,options:n,sortOptions:e,sortKey:s,translateLabel:m,$t:a,sortOrder:_})=>{let f=n!=null?[...n]:[];return f=f.filter(r=>r.condition==null?!0:r.condition!=null&&typeof r.condition=="function"?r.condition(t):r.condition),e&&(f.sort((r,l)=>{let o=(s==="label"?m?a(r.label):r.label:r.value).toLowerCase(),d=(s==="label"?m?a(l.label):l.label:l.value).toLowerCase();if(r.sort!=null&&l.sort==null){if(r.sort==="first")return-1;if(r.sort==="last")return 1}else if(r.sort==null&&l.sort!=null){if(l.sort==="first")return 1;if(l.sort==="last")return-1}else if(r.sort!=null&&l.sort!=null)return r.sort==="first"&&l.sort==="first"||r.sort==="last"&&l.sort==="last"?s==="label"?o.localeCompare(d):o<d?-1:o>d?1:0:r.sort<l.sort?-1:r.sort>l.sort?1:s==="label"?o.localeCompare(d):o<d?-1:o>d?1:0;return s==="label"?o.localeCompare(d):o<d?-1:o>d?1:0}),_.toLowerCase()!=="asc"&&f.reverse()),f},hasDefaultSlot:({$slots:t,hasSlot:n})=>!!t.default||n,hasLabelSlot:({$slots:t})=>!!t.label,hasDestroyFunction:({btnDestroy:t})=>typeof t=="function",hasErrors:({v:t})=>t!==null&&t.$error,errors:({v:t,$t:n})=>{let e={};return t!==null&&t.$errors.forEach(s=>{switch(s.$validator){case"required":e[s.$validator]=n("validationErrors.required-select");break;default:console.log("SelectInput - need to handle this error message"),console.log(s)}}),e}},methods:{blurSelect:function(t){this.validate(t.target.value),this.$emit("blur")},executeBtnDestroyAction:function(){this.btnDestroy!=null&&typeof this.btnDestroy=="function"&&this.id!=null&&this.btnDestroy(this.id)},validate:function(t){this.v!==null&&(t==null||t==="")&&this.v.$touch()},updateValue:function(t){t===""&&(t=null),this.v!==null&&this.v.$touch(),this.$emit("update:modelValue",t==="true"?!0:t==="false"?!1:t)},outputString:function(t,n){let e="";return typeof n=="function"?e=n(t):Array.isArray(n)?n.forEach((s,m)=>{m===0?e+=t[s]:e+=" - "+t[s]}):e=t[n],this.translateLabel&&(e=this.$t(e)),this.capitalizeLabel&&(e=w(e)),e}}},A=["for"],z={class:"text-truncate"},F={key:0,name:"help"},M={class:"popper__tooltip"},N={class:"input-group"},T=["id","value","name","disabled"],P=["value","disabled"],j=["value","disabled"],I={key:2,class:"input-group"},q=["id","value","name","disabled"],H=["value","disabled"],R=["value","disabled"],W={key:0,class:"select-input-error-message"},G=["innerHTML"];function J(t,n,e,s,m,a){const _=g("icon"),f=g("KPopper"),r=g("ButtonElement");return u(),i("div",{class:h({row:!e.vertical,[e.rowMargin]:e.rowMargin!=="","flex-grow-1":e.vertical})},[e.label||a.hasLabelSlot?(u(),i("label",{key:0,for:e.id,class:h(["form-label",{"col-xl-3":!e.vertical,"form-label-lg":!e.vertical,"justify-content-xl-end":!e.vertical}])},[S(t.$slots,"label",{},()=>[c("span",z,b(e.label),1)]),e.helpText!==null?(u(),i("div",F,[k(f,{hover:"",placement:"top",arrow:"","offset-distance":"15,0"},{content:B(()=>[c("div",M,b(e.helpText),1)]),default:B(()=>[k(_,{icon:["fal","info-circle"]})]),_:1})])):y("",!0)],10,A)):y("",!0),e.vertical?(u(),i("div",I,[c("select",{id:e.id,value:e.modelValue,name:e.id,disabled:e.disabled,class:"form-select",onChange:n[2]||(n[2]=l=>a.updateValue(l.target.value)),onBlur:n[3]||(n[3]=(...l)=>a.blurSelect&&a.blurSelect(...l))},[a.hasDefaultSlot?S(t.$slots,"default",{key:0}):(u(),i(v,{key:1},[e.showDefaultOption&&(e.defaultValue||e.defaultLabel)?(u(),i("option",{key:0,value:e.defaultValue,disabled:e.defaultDisabled,selected:""},b(t.$t(e.defaultLabel,{$capitalize:!0})),9,H)):y("",!0),(u(!0),i(v,null,V(a.conditionalOptions,(l,o)=>(u(),i("option",{key:o,value:l[e.optionValue],disabled:l.disabled===!0},b(a.outputString(l,e.optionLabel)),9,R))),128))],64))],40,q),a.hasDestroyFunction?(u(),D(r,{key:0,icon:["fal","xmark"],type:"button",variant:"tertiary",margin:"",size:"lg",action:a.executeBtnDestroyAction},null,8,["action"])):y("",!0)])):(u(),i("div",{key:1,class:h({"col-xl-9":!e.vertical,"offset-xl-3":!(e.label||a.hasLabelSlot)})},[c("div",N,[c("select",{id:e.id,value:e.modelValue,name:e.id,disabled:e.disabled,class:h(["form-select",{"col-xl-12":a.hasDestroyFunction}]),onChange:n[0]||(n[0]=l=>a.updateValue(l.target.value)),onBlur:n[1]||(n[1]=(...l)=>a.blurSelect&&a.blurSelect(...l))},[a.hasDefaultSlot?S(t.$slots,"default",{key:0}):(u(),i(v,{key:1},[e.showDefaultOption&&(e.defaultValue||e.defaultLabel)?(u(),i("option",{key:0,value:e.defaultValue,disabled:e.defaultDisabled,selected:""},b(t.$t(e.defaultLabel,{$capitalize:!0})),9,P)):y("",!0),(u(!0),i(v,null,V(a.conditionalOptions,(l,o)=>(u(),i("option",{key:o,value:l[e.optionValue],disabled:l.disabled===!0},b(a.outputString(l,e.optionLabel)),9,j))),128))],64))],42,T),a.hasDestroyFunction?(u(),D(r,{key:0,icon:["fal","xmark"],type:"button",variant:"tertiary",margin:"",size:"lg",action:a.executeBtnDestroyAction},null,8,["action"])):y("",!0)])],2)),c("div",{class:h({"col-xl-9":!e.vertical,"offset-xl-3":!e.vertical})},[a.hasErrors?(u(),i("div",W,[c("ul",null,[(u(!0),i(v,null,V(a.errors,(l,o)=>(u(),i("li",{key:o},[c("span",{innerHTML:l},null,8,G)]))),128))])])):y("",!0)],2)],2)}const U=x(O,[["render",J]]);export{U as S};