import{d as B,ar as H,A as d,bn as i,bo as p,bp as w,h as v,a9 as t,aa as L,by as N,br as h,bw as A,bs as E}from"../../../../common/preload-helper.BAt0wiQU.js";import{g as k,p as M}from"../../index.DetZ7Cvo.js";/* empty css                                                                                      */import"../../../../common/DnDDataTableControl.vue_vue_type_style_index_0_scoped_0b913e4f_lang.CI1SyTf2.js";/* empty css                                                                                                 */import{_ as $}from"../../../../common/LabelControl.vue_vue_type_script_setup_true_lang.8NM1WLzi.js";/* empty css                                                                                        */import{I as y}from"../../../../common/index.CaM6juwS.js";import{D as j}from"../../../../common/DeleteOutlined.zUdmm4WX.js";import{_ as q}from"../../../../common/_plugin-vue_export-helper.DlAUqK2U.js";import"../../../../common/index.Bkgl5HZD.js";import"../../../../common/motion.DDNFslEg.js";import"../../../../common/FormItemContext.B-agHi0o.js";import"../../../../common/createContext.DKLY0CB7.js";import"../../../../common/statusUtils.-yEA-Gfk.js";import"../../../../common/SearchOutlined.DEk5RLel.js";import"../../../../common/compact-item.CKdY6bQm.js";import"../../../../common/index.C2RKq64j.js";import"../../../../common/index.BQlS3R_s.js";import"../../../../common/index.2Llx5d_f.js";import"../../../../common/useState.9-uUdCQD.js";import"../../../../common/warning.Dss1f44C.js";import"../../../../common/isPlainObject.DBTCFiJr.js";import"../../../../common/index.K7lONbTM.js";const z={class:"wwp-row-handle"},F={class:"wwp-left-content"},R={class:"wwp-right-content"},S=["onClick"],G=["innerHTML"],J=B({__name:"OptionsControl",props:{params:{type:Object,required:!0}},emits:["input","fieldData"],setup(b,{emit:g}){const x=b,{params:O}=H(x),a=O.value,f=g,s=d([]),e=d([]),_=d(a.default),c=d(1);_.value.length>1?(c.value=_.value.length,_.value.forEach((l,n)=>{e.value=e.value.concat({key:n,value:l.value,text:l.text})})):e.value=e.value.concat({key:1,value:"",text:""});const C=k("optionValuePlaceholder",wp.i18n.__("Option Value","woocommerce-wholesale-prices")),V=k("optionTextPlaceholder",wp.i18n.__("Option Text","woocommerce-wholesale-prices")),I=(l,n)=>{const r=e.value.map(o=>o.key===l?{...o,value:n}:o);e.value=r,s.value[a.id]=e.value,f("fieldData",s.value)},D=(l,n)=>{const r=e.value.map(o=>o.key===l?{...o,text:n}:o);e.value=r,s.value[a.id]=e.value,f("fieldData",s.value)},T=()=>{c.value++,e.value=e.value.concat({key:c.value,value:"",text:""})},P=l=>{c.value--;const n=e.value.filter(r=>r.key!==l);e.value=n,s.value[a.id]=e.value,f("fieldData",s.value)};return(l,n)=>{var r,o;return i(),p("div",z,[w("div",F,[v(t($),{params:t(a)},null,8,["params"])]),w("div",R,[(i(!0),p(L,null,N(e.value,u=>(i(),p("div",{key:u.key,class:"wwp-options-control"},[v(t(y),{"default-value":u.value,placeholder:t(C),onInput:m=>I(u.key,m.target.value)},null,8,["default-value","placeholder","onInput"]),v(t(y),{"default-value":u.text,placeholder:t(V),onInput:m=>D(u.key,m.target.value)},null,8,["default-value","placeholder","onInput"]),c.value>1?(i(),p("a",{key:0,onClick:m=>P(u.key)},[v(t(j))],8,S)):h("",!0)]))),128)),t(a).btn_label!=="undefined"?(i(),p("button",{key:0,class:A(["wwp-options-btn",t(a).btn_classes]),type:"button",onClick:T},E(t(a).btn_label),3)):h("",!0),t(a).description!=="undefined"?(i(),p("p",{key:1,innerHTML:t(M)((o=(r=t(a))==null?void 0:r.description)!=null?o:"")},null,8,G)):h("",!0)])])}}}),he=q(J,[["__scopeId","data-v-a595eea6"]]);export{he as default};
