import{d as U,r as L,G as O,o as z,g as u,c as r,k as d,e as o,F as y,y as v,w as c,l as g,R as A,t as B,C as F,_ as H}from"./index-CUnFTKV2.js";const J={class:"reward-config-input"},S=U({__name:"RewardConfigInput",props:{modelValue:{}},emits:["update:modelValue"],setup(h,{emit:V}){const p=h,C=V,b=[{label:"钻石",value:"diamond"},{label:"HH币",value:"integral"},{label:"哈尼券",value:"score"}],a=L([{type:"diamond",amount:0}]),m=e=>{if(!e)return[{type:"diamond",amount:0}];try{const t=JSON.parse(e);if(Array.isArray(t)&&t.length>0)return t.map(n=>({type:n.type||"diamond",amount:n.amount||0}))}catch{}return[{type:"diamond",amount:0}]},w=e=>{const t=e.filter(n=>n.type&&n.amount>0);return t.length===0?"":JSON.stringify(t)};O(()=>p.modelValue,e=>{a.value=m(e)},{immediate:!0});const i=()=>{const e=w(a.value);C("update:modelValue",e)},x=()=>{a.value.push({type:"diamond",amount:0})},k=e=>{a.value.length>1&&(a.value.splice(e,1),i())};return z(()=>{a.value=m(p.modelValue)}),(e,t)=>{const n=u("el-option"),I=u("el-select"),R=u("el-input-number"),_=u("el-button"),N=u("el-icon");return d(),r("div",J,[(d(!0),r(y,null,v(a.value,(s,f)=>(d(),r("div",{key:f,class:"reward-item"},[o(I,{modelValue:s.type,"onUpdate:modelValue":l=>s.type=l,placeholder:"货币类型",style:{width:"120px"},onChange:i},{default:c(()=>[(d(),r(y,null,v(b,l=>o(n,{key:l.value,label:l.label,value:l.value},null,8,["label","value"])),64))]),_:1},8,["modelValue","onUpdate:modelValue"]),o(R,{modelValue:s.amount,"onUpdate:modelValue":l=>s.amount=l,min:0,max:999999999,placeholder:"数量",style:{width:"150px","margin-left":"8px"},onChange:i},null,8,["modelValue","onUpdate:modelValue"]),o(_,{type:"danger",icon:g(A),circle:"",size:"small",style:{"margin-left":"8px"},onClick:l=>k(f),disabled:a.value.length<=1},null,8,["icon","onClick","disabled"])]))),128)),o(_,{type:"primary",link:"",onClick:x,style:{"margin-top":"8px"}},{default:c(()=>[o(N,null,{default:c(()=>[o(g(F))]),_:1}),t[0]||(t[0]=B("添加货币 ",-1))]),_:1})])}}}),G=H(S,[["__scopeId","data-v-27f14406"]]);export{G as default};
