import{r as k,aa as p,aR as v}from"./index.02c939b6.js";import{d as b,c as y,g as _,E as h,o as l,i,F as x,t as E,a as V}from"./index.9838a17e.js";import{_ as A}from"./InputElTab.vue_vue_type_style_index_0_lang.1d1ad37c.js";const B={key:0,class:"border-theme-300 bg-theme-50 text-theme-400 rounded-lg border border-dashed py-2 px-4 text-sm"},O=b({__name:"InputRanking",props:{modelValue:{type:Array,default:()=>[]},list:{type:Array,default:()=>[]}},emits:["update:modelValue"],setup(g,{emit:f}){const s=g,u=k(),c=y(()=>(s.list?v(s.list):[]).sort((n,e)=>{const t=n.value,d=e.value,r=s.modelValue.indexOf(t),m=s.modelValue.indexOf(d);let o=0;return r<m?o=-1:r>m&&(o=1),o}));return _(async()=>{const a=u.value,n=()=>{const e=[];a==null||a.querySelectorAll("[data-value]").forEach(t=>{const r=t.dataset.value;r&&e.push(r)}),f("update:modelValue",e)};new h({wrapClass:"ranking",draggableClass:"ranking-item",ghostClasses:["ring-4","ring-theme-100","ring-offset-2"],onUpdate:()=>n()})}),(a,n)=>(l(),i("div",{ref_key:"rankingEl",ref:u,class:"ranking space-y-2"},[p(c).length==0?(l(),i("div",B," No options ")):(l(!0),i(x,{key:1},E(p(c),(e,t)=>(l(),V(A,{key:e.value,class:"ranking-item cursor-move",prefix:t+1,label:e.name,draggable:"true","data-value":e.value,icon:"i-carbon-draggable"},null,8,["prefix","label","data-value"]))),128))],512))}});export{O as default};
