import"./rolldown-runtime-BM3Ffeng.js";import{at as e,ut as t}from"./element-plus-vendor-BF9PNysW.js";import{A as n,D as r,I as i,O as a,Pt as o,Tt as s,Xt as c,bt as l,et as u,g as d,gt as f,ht as p,nt as m,qt as h,rt as g,v as _,x as v,y}from"./vue-vendor-DMUmTARL.js";import{t as b}from"./_plugin-vue_export-helper-CWyGVBf-.js";var x={key:1},S=[`aria-label`,`placeholder`,`onKeydown`],C=b(i({__name:`TagInput`,props:{modelValue:{type:Array,default:()=>[]},inputLabel:{type:String,default:`标签输入`},placeholder:{type:String,default:`+ 添加标签`},parseInput:{type:Function,default:void 0},tagType:{type:Function,default:void 0},tagTooltip:{type:Function,default:void 0}},emits:[`update:modelValue`,`change`],setup(i,{expose:b,emit:C}){let w=i,T=C,E=s(null),D=s(``),O=s(!1),k=e=>e.split(/[\n,，]+/).map(e=>e.trim()).filter(Boolean),A=()=>{E.value?.focus()},j=e=>w.tagType?.(e)||`info`,M=e=>w.tagTooltip?.(e)||``,N=e=>{T(`update:modelValue`,e),T(`change`)},P=()=>{O.value=!1;let e=D.value.trim();if(e){let t=(w.parseInput||k)(e),n=new Set(w.modelValue),r=!1;t.forEach(e=>{n.has(e)||(n.add(e),r=!0)}),r&&N(Array.from(n))}D.value=``},F=()=>{if(!D.value&&w.modelValue.length>0){let e=[...w.modelValue];e.pop(),N(e)}},I=e=>{N(w.modelValue.filter(t=>t!==e))};return b({focusInput:A}),(s,b)=>{let C=t,w=e;return u(),n(`div`,{class:h([`tag-input-container`,{"is-focus":o(O)}]),onClick:A},[(u(!0),n(v,null,m(i.modelValue,e=>(u(),a(w,{key:e,type:j(e),closable:``,size:`default`,class:`mb-2 mr-2 transition-all duration-200`,"disable-transitions":!1,onClose:t=>I(e)},{default:p(()=>[g(s.$slots,`tag`,{tag:e,tooltip:M(e)},()=>[M(e)?(u(),a(C,{key:0,content:M(e),placement:`top`,"show-after":200},{default:p(()=>[r(`span`,null,c(e),1)]),_:2},1032,[`content`])):(u(),n(`span`,x,c(e),1))],!0)]),_:2},1032,[`type`,`onClose`]))),128)),f(r(`input`,{ref_key:`inputRef`,ref:E,"onUpdate:modelValue":b[0]||=e=>l(D)?D.value=e:null,class:`mb-2 h-7 min-w-[80px] flex-1 bg-transparent text-sm leading-7 outline-none`,"aria-label":i.inputLabel,placeholder:i.placeholder,onFocus:b[1]||=e=>O.value=!0,onBlur:P,onKeydown:[_(y(P,[`prevent`]),[`enter`]),_(F,[`backspace`])]},null,40,S),[[d,o(D)]])],2)}}}),[[`__scopeId`,`data-v-9ca0546e`]]);export{C as t};