import{d as l}from"./vuedraggable.umd-BPF4oUW7.js";import{n as a}from"./index-Ms_1iFoB.js";const u={props:{input:Object,value:Array,toggleEdit:{type:Boolean,default:!0}},components:{draggable:l},data:()=>({item:null,inputItems:[],allItems:[]}),computed:{items:{get(){return this.value||[]},set(n){this.$emit("input",n)}}},mounted(){this.getItems()},methods:{getItems(){typeof this.input.items=="function"?this.inputItems=this.input.items():this.inputItems=this.input.items,this.allItems=[...this.inputItems]},getItem(n){return this.allItems.find(t=>t[this.input.itemValue]===n)},async addItem(){this.item&&(this.$emit("add",this.item),this.items.push(this.item),this.inputItems.splice(this.inputItems.indexOf(this.getItem(this.item)),1),await this.$nextTick(),this.item=null)},deleteItem(n){const t=this.items[n];t&&(this.$emit("delete",t),this.items.splice(n,1),this.inputItems.push(this.getItem(t)))},getItemName(n){var t;return((t=this.allItems.find(i=>(i==null?void 0:i[this.input.itemValue])===n))==null?void 0:t[this.input.itemText||"text"])??n}}};var m=function(){var t=this,i=t._self._c;return i("div",[i("v-list",{attrs:{dense:""}},[t.input.prefix?i("v-list-item",{key:"prefix",domProps:{textContent:t._s(t.input.prefix)}}):t._e(),t.input.prefix?i("v-icon",{staticClass:"ml-5"},[t._v("arrow_downward")]):t._e(),i("draggable",{attrs:{handle:".handle"},model:{value:t.items,callback:function(e){t.items=e},expression:"items"}},[t._l(t.items,function(e,s){return[i("v-list-item",{key:`${s}_${e}`},[i("v-list-item-action",{staticClass:"mr-0",staticStyle:{"min-width":"0px"}},[t._t("item-action",null,{item:e})],2),i("v-list-item-content",[i("v-row",{staticClass:"ma-0 d-block"},[t.toggleEdit?i("v-icon",{staticClass:"handle",staticStyle:{cursor:"move"},attrs:{color:"primary lighten-2"}},[t._v("drag_indicator")]):t._e(),i("span",{staticClass:"text-caption"},[t._v(" "+t._s(s+1)+".")]),i("span",{staticStyle:{"font-size":"0.9rem"}},[t._v(" "+t._s(t.getItemName(e))+" ")]),t.toggleEdit?i("v-btn",{attrs:{icon:"",small:"",color:"error"},on:{click:function(o){return t.deleteItem(s)}}},[i("v-icon",{attrs:{small:""}},[t._v("delete")])],1):t._e()],1)],1)],1)]})],2),t.input.prefix&&t.items.length>0?i("v-icon",{staticClass:"ml-5"},[t._v("arrow_downward")]):t._e(),t.input.suffix?i("v-list-item",{key:"suffix",domProps:{textContent:t._s(t.input.suffix)}}):t._e()],1),t.toggleEdit?i("div",[t.input.inputType==="text"?i("v-text-field",{attrs:{label:t.input.label,hint:t.input.hint,required:t.input.required,dense:"",maxlength:t.input.maxLength,"persistent-hint":!!t.input.hint,type:"text",suffix:t.input.suffix,prefix:t.input.prefix,"append-outer-icon":"add"},on:{keyup:function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"enter",13,e.key,"Enter")?null:t.addItem.apply(null,arguments)},"click:append-outer":t.addItem},model:{value:t.item,callback:function(e){t.item=typeof e=="string"?e.trim():e},expression:"item"}}):t._e(),t.input.inputType==="select"?i("v-select",{attrs:{label:t.input.label,hint:t.input.hint,"persistent-hint":!!t.input.hint,items:t.inputItems,"item-value":t.input.itemValue,"item-text":t.input.itemText,dense:""},on:{change:t.addItem},model:{value:t.item,callback:function(e){t.item=e},expression:"item"}}):t._e(),t.input.inputType==="autocomplete"?i("v-autocomplete",{attrs:{label:t.input.label,"persistent-hint":!!t.input.hint,hint:t.input.hint,items:t.inputItems,"item-value":t.input.itemValue,"item-text":t.input.itemText,dense:""},on:{change:t.addItem,keyup:function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"enter",13,e.key,"Enter")?null:t.addItem.apply(null,arguments)}},model:{value:t.item,callback:function(e){t.item=typeof e=="string"?e.trim():e},expression:"item"}}):t._e(),t.input.inputType==="combobox"?i("v-combobox",{attrs:{label:t.input.label,hint:t.input.hint,"persistent-hint":!!t.input.hint,items:t.inputItems,"item-value":t.input.itemValue,"item-text":t.input.itemText,dense:"",chips:"","deletable-chips":"","return-object":!1,"append-outer-icon":"add"},on:{change:t.addItem,keyup:function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"enter",13,e.key,"Enter")?null:t.addItem.apply(null,arguments)},"click:append-outer":t.addItem},model:{value:t.item,callback:function(e){t.item=typeof e=="string"?e.trim():e},expression:"item"}}):t._e()],1):t._e()],1)},p=[],r=a(u,m,p,!1,null,null);const h=r.exports;export{h as default};
