import{r as k,aa as p,aR as b}from"./index.ef672c15.js";import{d as v,c as h,h as y,G as _,o as l,a as i,F as x,x as V,b as A}from"./index.477073af.js";import{_ as B}from"./InputElTab.vue_vue_type_style_index_0_lang.0530f92b.js";const C={key:0,class:"border-theme-300 bg-theme-50 text-theme-400 rounded-lg border border-dashed py-2 px-4 text-sm"},O=v({__name:"InputRanking",props:{modelValue:{type:Array,default:()=>[]},list:{type:Array,default:()=>[]}},emits:["update:modelValue"],setup(f,{emit:g}){const s=f,u=k(),c=h(()=>(s.list?b(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 y(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)}),g("update:modelValue",e)};new _({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",C," No options ")):(l(!0),i(x,{key:1},V(p(c),(e,t)=>(l(),A(B,{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};
