import{_ as m,x as _,bn as g,ad as S,E as v,bo as C,G as b,ae as $,e as k,o as l,f as h,be as D,w as c,c as f,g as x,h as T,F as y,bp as I,a3 as O,i as B,t as F,a2 as w}from"./app-DGDivIsO.js";const E=_({props:["productData"],emits:["valueSuccess","valueChanged"],components:{SearchOutlined:g},setup(t,{emit:o}){const a=S({searchTerm:[],fetching:!1,products:[]});v(()=>{r(t)});const r=e=>{e.productData&&e.productData.product?(a.products=[{xid:e.productData.x_product_id,name:e.productData.product.name}],a.searchTerm=e.productData.x_product_id):(a.searchTerm=[],a.products=[]),o("valueSuccess")},i=(e,s)=>{o("valueChanged",e),o("valueSuccess")},p=C(e=>{if(a.products=[],e!=""){a.fetching=!0;const s=`name lk "%${e}%" or item_code lk "%${e}%"`;let d=`products?fields=xid,name&filters=${encodeURIComponent(s)}&limit=10`;axiosAdmin.get(d).then(u=>{a.products=u.data,a.fetching=!1})}},300);return b(t,(e,s)=>{r(e)}),{...$(a),fetchProducts:p,valueChanged:i}}});function N(t,o,a,r,i,p){const e=k("SearchOutlined"),s=I,d=w,u=O;return l(),h(u,{value:t.searchTerm,"onUpdate:value":o[0]||(o[0]=n=>t.searchTerm=n),"show-search":"","filter-option":!1,placeholder:t.$t("product.search_scan_product"),style:{width:"100%"},"not-found-content":t.fetching?void 0:null,onSearch:t.fetchProducts,"option-label-prop":"label",onChange:t.valueChanged,allowClear:!0},D({suffixIcon:c(()=>[f(e)]),default:c(()=>[(l(!0),x(y,null,T(t.products,n=>(l(),h(d,{key:n.xid,value:n.xid,label:n.name,product:n},{default:c(()=>[B(F(n.name),1)]),_:2},1032,["value","label","product"]))),128))]),_:2},[t.fetching?{name:"notFoundContent",fn:c(()=>[f(s,{size:"small"})]),key:"0"}:void 0]),1032,["value","placeholder","not-found-content","onSearch","onChange"])}const U=m(E,[["render",N]]);export{U as P};
